├── .gitattributes ├── .gitignore ├── AlertClient.lnk ├── AlertClient ├── AlertClient.csproj ├── App.config ├── Controls │ ├── Grouper.cs │ ├── HeaderPanel.Designer.cs │ ├── HeaderPanel.cs │ ├── HeaderPanel.resx │ └── NumericTextBox.cs ├── Forms │ ├── AboutForm.cs │ ├── AboutForm.designer.cs │ ├── AboutForm.resx │ ├── MainForm.Designer.cs │ ├── MainForm.cs │ └── MainForm.resx ├── Helpers │ ├── EventProcessor.cs │ ├── EventProcessorFactory.cs │ ├── EventProcessorFactoryConfiguration.cs │ ├── PropertyComparer.cs │ └── SortableBindingList.cs ├── Icons │ ├── AzureLogo.ico │ ├── Tool.ico │ └── WindowsAzureLogo.ico ├── Images │ ├── AzureLogo.png │ ├── SmallDocument.png │ ├── SmallWorld.png │ ├── Warning.png │ └── WhiteLogo.png ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── packages.config ├── DeviceActorService.Interfaces ├── DeviceActorService.Interfaces.csproj ├── IDeviceActor.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── DeviceActorService ├── ActorEventSource.cs ├── App.config ├── ApplicationInsights.config ├── DeviceActor.cs ├── DeviceActorService.cs ├── DeviceActorService.csproj ├── PackageRoot │ ├── Config │ │ └── Settings.xml │ └── ServiceManifest.xml ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Service References │ └── Application Insights │ │ └── ConnectedService.json └── packages.config ├── DeviceManagementWebService ├── App.config ├── App_Start │ └── BrowserJsonFormatter.cs ├── Controllers │ └── DeviceController.cs ├── DeviceManagementWebService.cs ├── DeviceManagementWebService.csproj ├── IOwinAppBuilder.cs ├── OwinCommunicationListener.cs ├── PackageRoot │ ├── Config │ │ └── Settings.xml │ └── ServiceManifest.xml ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── ServiceEventSource.cs ├── Startup.cs └── packages.config ├── DeviceSimulator.lnk ├── DeviceSimulator ├── App.config ├── Controls │ ├── Grouper.cs │ ├── HeaderPanel.Designer.cs │ ├── HeaderPanel.cs │ ├── HeaderPanel.resx │ ├── NumericTextBox.cs │ ├── TrackBar.cs │ ├── TrackBar.resx │ └── TrackBarDesigner.cs ├── DeviceSimulator.csproj ├── Forms │ ├── AboutForm.cs │ ├── AboutForm.designer.cs │ ├── AboutForm.resx │ ├── MainForm.Designer.cs │ ├── MainForm.cs │ └── MainForm.resx ├── Helpers │ ├── CustomColorHelper.cs │ └── CustomStyleHelper.cs ├── Icons │ ├── AzureLogo.ico │ ├── Tool.ico │ └── WindowsAzureLogo.ico ├── Images │ ├── AzureLogo.png │ ├── SmallDocument.png │ ├── SmallWorld.png │ ├── Warning.png │ └── WhiteLogo.png ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── packages.config ├── Entities ├── Alert.cs ├── Device.cs ├── Payload.cs ├── PayloadEntities.csproj ├── Properties │ └── AssemblyInfo.cs ├── app.config └── packages.config ├── EventProcessorHostService ├── App.config ├── EventProcessor.cs ├── EventProcessorFactory.cs ├── EventProcessorHostListener.cs ├── EventProcessorHostService.cs ├── EventProcessorHostService.csproj ├── PackageRoot │ ├── Config │ │ └── Settings.xml │ └── ServiceManifest.xml ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── ServiceEventSource.cs └── packages.config ├── Images ├── AlertClient.png ├── DeviceSimulator.png └── VerticalArchitectureDesign.png ├── IoTDemo.sln ├── IoTDemo ├── ApplicationPackageRoot │ └── ApplicationManifest.xml ├── ApplicationParameters │ ├── Cloud.xml │ └── Local.xml ├── IoTDemo.sfproj ├── PublishProfiles │ ├── Cloud.xml │ └── Local.xml └── Scripts │ └── Deploy-FabricApplication.ps1 ├── README.md └── _config.yml /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | # DNX 42 | project.lock.json 43 | artifacts/ 44 | 45 | *_i.c 46 | *_p.c 47 | *_i.h 48 | *.ilk 49 | *.meta 50 | *.obj 51 | *.pch 52 | *.pdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *.log 63 | *.vspscc 64 | *.vssscc 65 | .builds 66 | *.pidb 67 | *.svclog 68 | *.scc 69 | 70 | # Chutzpah Test files 71 | _Chutzpah* 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opensdf 78 | *.sdf 79 | *.cachefile 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | *.vspx 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding add-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | 110 | # MightyMoose 111 | *.mm.* 112 | AutoTest.Net/ 113 | 114 | # Web workbench (sass) 115 | .sass-cache/ 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.[Pp]ublish.xml 135 | *.azurePubxml 136 | ## TODO: Comment the next line if you want to checkin your 137 | ## web deploy settings but do note that will include unencrypted 138 | ## passwords 139 | #*.pubxml 140 | 141 | *.publishproj 142 | 143 | # NuGet Packages 144 | *.nupkg 145 | # The packages folder can be ignored because of Package Restore 146 | **/packages/* 147 | # except build/, which is used as an MSBuild target. 148 | !**/packages/build/ 149 | # Uncomment if necessary however generally it will be regenerated when needed 150 | #!**/packages/repositories.config 151 | 152 | # Windows Azure Build Output 153 | csx/ 154 | *.build.csdef 155 | 156 | # Windows Store app package directory 157 | AppPackages/ 158 | 159 | # Visual Studio cache files 160 | # files ending in .cache can be ignored 161 | *.[Cc]ache 162 | # but keep track of directories ending in .cache 163 | !*.[Cc]ache/ 164 | 165 | # Others 166 | ClientBin/ 167 | [Ss]tyle[Cc]op.* 168 | ~$* 169 | *~ 170 | *.dbmdl 171 | *.dbproj.schemaview 172 | *.pfx 173 | *.publishsettings 174 | node_modules/ 175 | orleans.codegen.cs 176 | 177 | # RIA/Silverlight projects 178 | Generated_Code/ 179 | 180 | # Backup & report files from converting an old project file 181 | # to a newer Visual Studio version. Backup files are not needed, 182 | # because we have git ;-) 183 | _UpgradeReport_Files/ 184 | Backup*/ 185 | UpgradeLog*.XML 186 | UpgradeLog*.htm 187 | 188 | # SQL Server files 189 | *.mdf 190 | *.ldf 191 | 192 | # Business Intelligence projects 193 | *.rdl.data 194 | *.bim.layout 195 | *.bim_*.settings 196 | 197 | # Microsoft Fakes 198 | FakesAssemblies/ 199 | 200 | # Node.js Tools for Visual Studio 201 | .ntvs_analysis.dat 202 | 203 | # Visual Studio 6 build log 204 | *.plg 205 | 206 | # Visual Studio 6 workspace options file 207 | *.opt 208 | 209 | # LightSwitch generated files 210 | GeneratedArtifacts/ 211 | _Pvt_Extensions/ 212 | ModelManifest.xml 213 | -------------------------------------------------------------------------------- /AlertClient.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/AlertClient.lnk -------------------------------------------------------------------------------- /AlertClient/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /AlertClient/Controls/HeaderPanel.Designer.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace Microsoft.AzureCat.Samples.AlertClient 4 | { 5 | partial class HeaderPanel 6 | { 7 | /// 8 | /// Required designer variable. 9 | /// 10 | private IContainer components = null; 11 | 12 | /// 13 | /// Clean up any resources being used. 14 | /// 15 | /// true if managed resources should be disposed; otherwise, false. 16 | protected override void Dispose(bool disposing) 17 | { 18 | if (disposing && (components != null)) 19 | { 20 | components.Dispose(); 21 | } 22 | base.Dispose(disposing); 23 | } 24 | 25 | #region Component Designer generated code 26 | 27 | /// 28 | /// Required method for Designer support - do not modify 29 | /// the contents of this method with the code editor. 30 | /// 31 | private void InitializeComponent() 32 | { 33 | this.SuspendLayout(); 34 | // 35 | // OutlookPanelEx 36 | // 37 | this.BackColor = System.Drawing.SystemColors.ControlLightLight; 38 | this.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); 39 | this.Name = "OutlookPanelEx"; 40 | this.Size = new System.Drawing.Size(224, 172); 41 | this.Paint += new System.Windows.Forms.PaintEventHandler(this.OutlookPanelEx_Paint); 42 | this.ResumeLayout(false); 43 | 44 | } 45 | 46 | #endregion 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /AlertClient/Controls/HeaderPanel.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/AlertClient/Controls/HeaderPanel.cs -------------------------------------------------------------------------------- /AlertClient/Controls/HeaderPanel.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /AlertClient/Controls/NumericTextBox.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Business Platform Division Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on my personal 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2011 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Globalization; 22 | using System.Windows.Forms; 23 | 24 | #endregion 25 | 26 | namespace Microsoft.AzureCat.Samples.AlertClient 27 | { 28 | public class NumericTextBox : TextBox 29 | { 30 | #region Private Fields 31 | private bool allowSpace; 32 | #endregion 33 | 34 | #region Protected Methods 35 | // Restricts the entry of characters to digits (including hex), the negative sign, 36 | // the decimal point, and editing keystrokes (backspace). 37 | protected override void OnKeyPress(KeyPressEventArgs e) 38 | { 39 | base.OnKeyPress(e); 40 | 41 | var numberFormatInfo = CultureInfo.CurrentCulture.NumberFormat; 42 | var decimalSeparator = numberFormatInfo.NumberDecimalSeparator; 43 | var groupSeparator = numberFormatInfo.NumberGroupSeparator; 44 | var negativeSign = numberFormatInfo.NegativeSign; 45 | 46 | var keyInput = e.KeyChar.ToString(CultureInfo.InvariantCulture); 47 | 48 | if (Char.IsDigit(e.KeyChar)) 49 | { 50 | // Digits are OK 51 | } 52 | else if (keyInput.Equals(decimalSeparator) || keyInput.Equals(groupSeparator) || 53 | keyInput.Equals(negativeSign)) 54 | { 55 | // Decimal separator is OK 56 | } 57 | else if (e.KeyChar == '\b') 58 | { 59 | // Backspace key is OK 60 | } 61 | // else if ((ModifierKeys & (Keys.Control | Keys.Alt)) != 0) 62 | // { 63 | // // Let the edit control handle control and alt key combinations 64 | // } 65 | else if (allowSpace && e.KeyChar == ' ') 66 | { 67 | 68 | } 69 | else 70 | { 71 | // Swallow this invalid key and beep 72 | e.Handled = true; 73 | } 74 | } 75 | #endregion 76 | 77 | #region Public Properties 78 | public int IntegerValue 79 | { 80 | get { return Int32.Parse(Text); } 81 | } 82 | 83 | public decimal DecimalValue 84 | { 85 | get { return Decimal.Parse(Text); } 86 | } 87 | 88 | public bool AllowSpace 89 | { 90 | set { allowSpace = value; } 91 | 92 | get { return allowSpace; } 93 | } 94 | #endregion 95 | } 96 | } -------------------------------------------------------------------------------- /AlertClient/Helpers/EventProcessor.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.Linq; 23 | using System.Text; 24 | using System.Threading.Tasks; 25 | using Microsoft.AzureCat.Samples.PayloadEntities; 26 | using Microsoft.ServiceBus.Messaging; 27 | using Newtonsoft.Json; 28 | 29 | #endregion 30 | 31 | namespace Microsoft.AzureCat.Samples.AlertClient 32 | { 33 | public class EventProcessor : IEventProcessor 34 | { 35 | #region Private Fields 36 | 37 | private EventProcessorFactoryConfiguration configuration; 38 | #endregion 39 | 40 | #region Public Constructors 41 | public EventProcessor(EventProcessorFactoryConfiguration configuration) 42 | { 43 | if (configuration == null) 44 | { 45 | throw new ArgumentNullException(nameof(configuration)); 46 | } 47 | this.configuration = configuration; 48 | } 49 | #endregion 50 | 51 | #region IEventProcessor Methods 52 | public Task OpenAsync(PartitionContext context) 53 | { 54 | try 55 | { 56 | // Trace Open Partition 57 | configuration.WriteToLog($"[EventProcessor].[OpenAsync]:: EventHub=[{context.EventHubPath}] ConsumerGroup=[{context.ConsumerGroupName}] PartitionId=[{context.Lease.PartitionId}]"); 58 | } 59 | catch (Exception ex) 60 | { 61 | // Trace Exception 62 | configuration.WriteToLog($"[EventProcessor].[OpenAsync]:: Exception=[{ex.Message}]"); 63 | } 64 | return Task.FromResult(null); 65 | } 66 | 67 | public async Task ProcessEventsAsync(PartitionContext context, IEnumerable events) 68 | { 69 | try 70 | { 71 | var eventDatas = events as EventData[] ?? events.ToArray(); 72 | if (events == null || !eventDatas.Any()) 73 | { 74 | return; 75 | } 76 | var eventDataList = events as IList ?? eventDatas.ToList(); 77 | 78 | // Trace Process Events 79 | configuration.WriteToLog($"[EventProcessor].[ProcessEventsAsync]:: EventHub=[{context.EventHubPath}] ConsumerGroup=[{context.ConsumerGroupName}] PartitionId=[{context.Lease.PartitionId}] EventCount=[{eventDataList.Count}]"); 80 | 81 | // Trace individual events 82 | foreach (var alert in eventDataList.Select(DeserializeEventData).Where(alert => alert != null)) 83 | { 84 | // Trace Payload 85 | configuration.WriteToLog($"[Alert] DeviceId=[{alert.DeviceId:000}] " + 86 | $"Name=[{alert.Name}] " + 87 | $"Value=[{alert.Value:000}] " + 88 | $"Timestamp=[{alert.Timestamp}]"); 89 | 90 | // Track event 91 | configuration.TrackEvent(alert); 92 | } 93 | 94 | // Checkpoint 95 | await context.CheckpointAsync(); 96 | } 97 | catch (AggregateException ex) 98 | { 99 | // Trace Exception 100 | foreach (var exception in ex.InnerExceptions) 101 | { 102 | configuration.WriteToLog(exception.Message); 103 | } 104 | } 105 | catch (Exception ex) 106 | { 107 | // Trace Exception 108 | configuration.WriteToLog($"[EventProcessor].[ProcessEventsAsync]:: Exception=[{ex.Message}]"); 109 | } 110 | } 111 | 112 | public async Task CloseAsync(PartitionContext context, CloseReason reason) 113 | { 114 | try 115 | { 116 | // Trace Open Partition 117 | configuration.WriteToLog($"[EventProcessor].[CloseAsync]:: EventHub=[{context.EventHubPath}] ConsumerGroup=[{context.ConsumerGroupName}] PartitionId=[{context.Lease.PartitionId}] Reason=[{reason}]"); 118 | 119 | if (reason == CloseReason.Shutdown) 120 | { 121 | await context.CheckpointAsync(); 122 | } 123 | } 124 | catch (LeaseLostException) 125 | { 126 | } 127 | catch (Exception ex) 128 | { 129 | // Trace Exception 130 | configuration.WriteToLog($"[EventProcessor].[CloseAsync]:: Exception=[{ex.Message}]"); 131 | } 132 | } 133 | #endregion 134 | 135 | #region Private Static Methods 136 | private static Alert DeserializeEventData(EventData eventData) 137 | { 138 | return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(eventData.GetBytes())); 139 | } 140 | #endregion 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /AlertClient/Helpers/EventProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using Microsoft.ServiceBus.Messaging; 22 | 23 | #endregion 24 | 25 | namespace Microsoft.AzureCat.Samples.AlertClient 26 | { 27 | public class EventProcessorFactory : IEventProcessorFactory where T : class, IEventProcessor 28 | { 29 | #region Private Fields 30 | private readonly T instance; 31 | private readonly EventProcessorFactoryConfiguration configuration; 32 | #endregion 33 | 34 | #region Public Constructors 35 | public EventProcessorFactory() 36 | { 37 | configuration = null; 38 | } 39 | 40 | public EventProcessorFactory(EventProcessorFactoryConfiguration configuration) 41 | { 42 | this.configuration = configuration; 43 | } 44 | 45 | public EventProcessorFactory(T instance) 46 | { 47 | this.instance = instance; 48 | } 49 | #endregion 50 | 51 | #region IEventProcessorFactory Methods 52 | public IEventProcessor CreateEventProcessor(PartitionContext context) 53 | { 54 | return instance ?? Activator.CreateInstance(typeof(T), configuration) as T; 55 | } 56 | #endregion 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /AlertClient/Helpers/EventProcessorFactoryConfiguration.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using Microsoft.AzureCat.Samples.PayloadEntities; 22 | 23 | #endregion 24 | 25 | namespace Microsoft.AzureCat.Samples.AlertClient 26 | { 27 | public class EventProcessorFactoryConfiguration 28 | { 29 | #region Public Properties 30 | public Action TrackEvent { get; set; } 31 | public Action WriteToLog { get; set; } 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /AlertClient/Helpers/PropertyComparer.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System.Collections; 21 | using System.Collections.Generic; 22 | using System.ComponentModel; 23 | using System.Reflection; 24 | 25 | #endregion 26 | 27 | namespace Microsoft.AzureCat.Samples.AlertClient 28 | { 29 | public class PropertyComparer : IComparer 30 | { 31 | #region Private Properties 32 | private readonly IComparer comparer; 33 | private PropertyDescriptor propertyDescriptor; 34 | private int reverse; 35 | #endregion 36 | 37 | #region Public Constructor 38 | public PropertyComparer(PropertyDescriptor property, ListSortDirection direction) 39 | { 40 | propertyDescriptor = property; 41 | var comparerForPropertyType = typeof(Comparer<>).MakeGenericType(property.PropertyType); 42 | comparer = (IComparer)comparerForPropertyType.InvokeMember("Default", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.Public, null, null, null); 43 | SetListSortDirection(direction); 44 | } 45 | #endregion 46 | 47 | #region IComparer Members 48 | 49 | public int Compare(T x, T y) 50 | { 51 | return reverse * comparer.Compare(propertyDescriptor.GetValue(x), propertyDescriptor.GetValue(y)); 52 | } 53 | 54 | #endregion 55 | 56 | #region Public Methods 57 | public void SetPropertyAndDirection(PropertyDescriptor descriptor, ListSortDirection direction) 58 | { 59 | SetPropertyDescriptor(descriptor); 60 | SetListSortDirection(direction); 61 | } 62 | #endregion 63 | 64 | #region Private Methods 65 | private void SetPropertyDescriptor(PropertyDescriptor descriptor) 66 | { 67 | propertyDescriptor = descriptor; 68 | } 69 | 70 | private void SetListSortDirection(ListSortDirection direction) 71 | { 72 | reverse = direction == ListSortDirection.Ascending ? 1 : -1; 73 | } 74 | #endregion 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /AlertClient/Helpers/SortableBindingList.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.ComponentModel; 23 | 24 | #endregion 25 | 26 | namespace Microsoft.AzureCat.Samples.AlertClient 27 | { 28 | public class SortableBindingList : BindingList 29 | { 30 | private readonly Dictionary> comparers; 31 | private bool isSorted; 32 | private ListSortDirection listSortDirection; 33 | private PropertyDescriptor propertyDescriptor; 34 | 35 | public SortableBindingList() 36 | : base(new List()) 37 | { 38 | comparers = new Dictionary>(); 39 | } 40 | 41 | public SortableBindingList(IEnumerable enumeration) 42 | : base(new List(enumeration)) 43 | { 44 | comparers = new Dictionary>(); 45 | } 46 | 47 | protected override bool SupportsSortingCore 48 | { 49 | get { return true; } 50 | } 51 | 52 | protected override bool IsSortedCore 53 | { 54 | get { return isSorted; } 55 | } 56 | 57 | protected override PropertyDescriptor SortPropertyCore 58 | { 59 | get { return propertyDescriptor; } 60 | } 61 | 62 | protected override ListSortDirection SortDirectionCore 63 | { 64 | get { return listSortDirection; } 65 | } 66 | 67 | protected override bool SupportsSearchingCore 68 | { 69 | get { return true; } 70 | } 71 | 72 | protected override void ApplySortCore(PropertyDescriptor property, ListSortDirection direction) 73 | { 74 | var itemsList = (List)Items; 75 | 76 | var propertyType = property.PropertyType; 77 | PropertyComparer comparer; 78 | if (!comparers.TryGetValue(propertyType, out comparer)) 79 | { 80 | comparer = new PropertyComparer(property, direction); 81 | comparers.Add(propertyType, comparer); 82 | } 83 | 84 | comparer.SetPropertyAndDirection(property, direction); 85 | itemsList.Sort(comparer); 86 | 87 | propertyDescriptor = property; 88 | listSortDirection = direction; 89 | isSorted = true; 90 | 91 | OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1)); 92 | } 93 | 94 | protected override void RemoveSortCore() 95 | { 96 | isSorted = false; 97 | propertyDescriptor = base.SortPropertyCore; 98 | listSortDirection = base.SortDirectionCore; 99 | 100 | OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1)); 101 | } 102 | 103 | protected override int FindCore(PropertyDescriptor property, object key) 104 | { 105 | var count = Count; 106 | for (var i = 0; i < count; ++i) 107 | { 108 | var element = this[i]; 109 | var value = property.GetValue(element); 110 | if (value != null && value.Equals(key)) 111 | { 112 | return i; 113 | } 114 | } 115 | return -1; 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /AlertClient/Icons/AzureLogo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/AlertClient/Icons/AzureLogo.ico -------------------------------------------------------------------------------- /AlertClient/Icons/Tool.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/AlertClient/Icons/Tool.ico -------------------------------------------------------------------------------- /AlertClient/Icons/WindowsAzureLogo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/AlertClient/Icons/WindowsAzureLogo.ico -------------------------------------------------------------------------------- /AlertClient/Images/AzureLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/AlertClient/Images/AzureLogo.png -------------------------------------------------------------------------------- /AlertClient/Images/SmallDocument.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/AlertClient/Images/SmallDocument.png -------------------------------------------------------------------------------- /AlertClient/Images/SmallWorld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/AlertClient/Images/SmallWorld.png -------------------------------------------------------------------------------- /AlertClient/Images/Warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/AlertClient/Images/Warning.png -------------------------------------------------------------------------------- /AlertClient/Images/WhiteLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/AlertClient/Images/WhiteLogo.png -------------------------------------------------------------------------------- /AlertClient/Program.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Windows.Forms; 22 | 23 | #endregion 24 | 25 | namespace Microsoft.AzureCat.Samples.AlertClient 26 | { 27 | static class Program 28 | { 29 | /// 30 | /// The main entry point for the application. 31 | /// 32 | [STAThread] 33 | static void Main() 34 | { 35 | Application.EnableVisualStyles(); 36 | Application.SetCompatibleTextRenderingDefault(false); 37 | Application.Run(new MainForm()); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /AlertClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("EventSender")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("EventSender")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("25791060-8870-4d2d-a58a-d4cb91105e88")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /AlertClient/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.0 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System.CodeDom.Compiler; 12 | using System.ComponentModel; 13 | using System.Diagnostics; 14 | using System.Diagnostics.CodeAnalysis; 15 | using System.Drawing; 16 | using System.Globalization; 17 | using System.Resources; 18 | using System.Runtime.CompilerServices; 19 | 20 | namespace Microsoft.AzureCat.Samples.AlertClient.Properties { 21 | /// 22 | /// A strongly-typed resource class, for looking up localized strings, etc. 23 | /// 24 | // This class was auto-generated by the StronglyTypedResourceBuilder 25 | // class via a tool like ResGen or Visual Studio. 26 | // To add or remove a member, edit your .ResX file then rerun ResGen 27 | // with the /str option, or rebuild your VS project. 28 | [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 29 | [DebuggerNonUserCode()] 30 | [CompilerGenerated()] 31 | internal class Resources { 32 | 33 | private static ResourceManager resourceMan; 34 | 35 | private static CultureInfo resourceCulture; 36 | 37 | [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 38 | internal Resources() { 39 | } 40 | 41 | /// 42 | /// Returns the cached ResourceManager instance used by this class. 43 | /// 44 | [EditorBrowsable(EditorBrowsableState.Advanced)] 45 | internal static ResourceManager ResourceManager { 46 | get { 47 | if (ReferenceEquals(resourceMan, null)) { 48 | ResourceManager temp = new ResourceManager("Microsoft.AzureCat.Samples.AlertClient.Properties.Resources", typeof(Resources).Assembly); 49 | resourceMan = temp; 50 | } 51 | return resourceMan; 52 | } 53 | } 54 | 55 | /// 56 | /// Overrides the current thread's CurrentUICulture property for all 57 | /// resource lookups using this strongly typed resource class. 58 | /// 59 | [EditorBrowsable(EditorBrowsableState.Advanced)] 60 | internal static CultureInfo Culture { 61 | get { 62 | return resourceCulture; 63 | } 64 | set { 65 | resourceCulture = value; 66 | } 67 | } 68 | 69 | /// 70 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 71 | /// 72 | internal static Icon AzureLogo { 73 | get { 74 | object obj = ResourceManager.GetObject("AzureLogo", resourceCulture); 75 | return ((Icon)(obj)); 76 | } 77 | } 78 | 79 | /// 80 | /// Looks up a localized resource of type System.Drawing.Bitmap. 81 | /// 82 | internal static Bitmap AzureLogo1 { 83 | get { 84 | object obj = ResourceManager.GetObject("AzureLogo1", resourceCulture); 85 | return ((Bitmap)(obj)); 86 | } 87 | } 88 | 89 | /// 90 | /// Looks up a localized resource of type System.Drawing.Bitmap. 91 | /// 92 | internal static Bitmap SmallDocument { 93 | get { 94 | object obj = ResourceManager.GetObject("SmallDocument", resourceCulture); 95 | return ((Bitmap)(obj)); 96 | } 97 | } 98 | 99 | /// 100 | /// Looks up a localized resource of type System.Drawing.Bitmap. 101 | /// 102 | internal static Bitmap SmallWorld { 103 | get { 104 | object obj = ResourceManager.GetObject("SmallWorld", resourceCulture); 105 | return ((Bitmap)(obj)); 106 | } 107 | } 108 | 109 | /// 110 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 111 | /// 112 | internal static Icon Tool { 113 | get { 114 | object obj = ResourceManager.GetObject("Tool", resourceCulture); 115 | return ((Icon)(obj)); 116 | } 117 | } 118 | 119 | /// 120 | /// Looks up a localized resource of type System.Drawing.Bitmap. 121 | /// 122 | internal static Bitmap Warning { 123 | get { 124 | object obj = ResourceManager.GetObject("Warning", resourceCulture); 125 | return ((Bitmap)(obj)); 126 | } 127 | } 128 | 129 | /// 130 | /// Looks up a localized resource of type System.Drawing.Bitmap. 131 | /// 132 | internal static Bitmap WhiteLogo { 133 | get { 134 | object obj = ResourceManager.GetObject("WhiteLogo", resourceCulture); 135 | return ((Bitmap)(obj)); 136 | } 137 | } 138 | 139 | /// 140 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 141 | /// 142 | internal static Icon WindowsAzureLogo { 143 | get { 144 | object obj = ResourceManager.GetObject("WindowsAzureLogo", resourceCulture); 145 | return ((Icon)(obj)); 146 | } 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /AlertClient/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Icons\AzureLogo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | ..\Images\AzureLogo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 126 | 127 | 128 | ..\Images\SmallDocument.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 129 | 130 | 131 | ..\Images\SmallWorld.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 132 | 133 | 134 | ..\Icons\Tool.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 135 | 136 | 137 | ..\Images\Warning.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 138 | 139 | 140 | ..\Images\WhiteLogo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 141 | 142 | 143 | ..\Icons\WindowsAzureLogo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 144 | 145 | -------------------------------------------------------------------------------- /AlertClient/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.0 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System.CodeDom.Compiler; 12 | using System.Configuration; 13 | using System.Runtime.CompilerServices; 14 | 15 | namespace Microsoft.AzureCat.Samples.AlertClient.Properties { 16 | 17 | 18 | [CompilerGenerated()] 19 | [GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 20 | internal sealed partial class Settings : ApplicationSettingsBase { 21 | 22 | private static Settings defaultInstance = ((Settings)(Synchronized(new Settings()))); 23 | 24 | public static Settings Default { 25 | get { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /AlertClient/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AlertClient/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /DeviceActorService.Interfaces/DeviceActorService.Interfaces.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x64 7 | {5053282C-E247-4FCB-8AEE-B45DF9C877C0} 8 | Library 9 | Properties 10 | Microsoft.AzureCat.Samples.DeviceActorService.Interfaces 11 | Microsoft.AzureCat.Samples.DeviceActorService.Interfaces 12 | v4.5.1 13 | 512 14 | 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\x64\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | x64 25 | MinimumRecommendedRules.ruleset 26 | 27 | 28 | pdbonly 29 | true 30 | bin\x64\Release\ 31 | TRACE 32 | prompt 33 | x64 34 | MinimumRecommendedRules.ruleset 35 | 36 | 37 | 38 | ..\packages\Microsoft.ServiceFabric.Actors.2.0.135\lib\net45\Microsoft.ServiceFabric.Actors.dll 39 | True 40 | 41 | 42 | ..\packages\Microsoft.ServiceFabric.Data.2.0.135\lib\net45\Microsoft.ServiceFabric.Data.dll 43 | True 44 | 45 | 46 | ..\packages\Microsoft.ServiceFabric.Data.2.0.135\lib\net45\Microsoft.ServiceFabric.Data.Interfaces.dll 47 | True 48 | 49 | 50 | ..\packages\Microsoft.ServiceFabric.5.0.135\lib\net45\Microsoft.ServiceFabric.Internal.dll 51 | True 52 | 53 | 54 | ..\packages\Microsoft.ServiceFabric.5.0.135\lib\net45\Microsoft.ServiceFabric.Internal.Strings.dll 55 | True 56 | 57 | 58 | ..\packages\Microsoft.ServiceFabric.Services.2.0.135\lib\net45\Microsoft.ServiceFabric.Services.dll 59 | True 60 | 61 | 62 | ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll 63 | True 64 | 65 | 66 | 67 | 68 | ..\packages\Microsoft.ServiceFabric.5.0.135\lib\net45\System.Fabric.dll 69 | True 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | {aa413fd4-fd2b-4b29-864c-e42915767176} 84 | PayloadEntities 85 | 86 | 87 | 88 | 89 | 90 | 91 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /DeviceActorService.Interfaces/IDeviceActor.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System.Threading.Tasks; 21 | using Microsoft.AzureCat.Samples.PayloadEntities; 22 | using Microsoft.ServiceFabric.Actors; 23 | 24 | #endregion 25 | 26 | // ReSharper disable once CheckNamespace 27 | namespace Microsoft.AzureCat.Samples.DeviceActorService.Interfaces 28 | { 29 | public interface IDeviceActor : IActor 30 | { 31 | Task ProcessEventAsync(Payload payload); 32 | Task SetData(Device data); 33 | Task GetData(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /DeviceActorService.Interfaces/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("DeviceActorService.Interfaces")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("DeviceActorService.Interfaces")] 12 | [assembly: AssemblyCopyright("Copyright © 2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("5053282c-e247-4fcb-8aee-b45df9c877c0")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /DeviceActorService.Interfaces/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DeviceActorService/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /DeviceActorService/ApplicationInsights.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 760544d2-1fe8-4c72-92a9-6f2651b07c9b 4 | 5 | 6 | 5 7 | 8 | 9 | 10 | 11 | 12 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /DeviceActorService/DeviceActorService.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Fabric; 22 | using Microsoft.ServiceFabric.Actors.Runtime; 23 | 24 | #endregion 25 | 26 | namespace Microsoft.AzureCat.Samples.DeviceActorService 27 | { 28 | 29 | public class DeviceActorService : ActorService 30 | { 31 | #region Private Constants 32 | //************************************ 33 | // Parameters 34 | //************************************ 35 | private const string ConfigurationPackage = "Config"; 36 | private const string ConfigurationSection = "DeviceActorServiceConfig"; 37 | private const string ServiceBusConnectionStringParameter = "ServiceBusConnectionString"; 38 | private const string EventHubNameParameter = "EventHubName"; 39 | private const string QueueLengthParameter = "QueueLength"; 40 | 41 | //************************************ 42 | // Formats 43 | //************************************ 44 | private const string ParameterCannotBeNullFormat = "The parameter [{0}] is not defined in the Setting.xml configuration file."; 45 | 46 | //************************************ 47 | // Constants 48 | //************************************ 49 | private const int DefaultQueueLength = 100; 50 | #endregion 51 | 52 | #region Public Constructor 53 | 54 | public DeviceActorService(StatefulServiceContext context, 55 | ActorTypeInformation typeInfo, 56 | Func actorFactory = null, 57 | IActorStateProvider stateProvider = null, 58 | ActorServiceSettings settings = null) 59 | : base(context, typeInfo, actorFactory, stateProvider, settings) 60 | { 61 | // Read settings from the DeviceActorServiceConfig section in the Settings.xml file 62 | var activationContext = Context.CodePackageActivationContext; 63 | var config = activationContext.GetConfigurationPackageObject(ConfigurationPackage); 64 | var section = config.Settings.Sections[ConfigurationSection]; 65 | 66 | // Read the ServiceBusConnectionString setting from the Settings.xml file 67 | var parameter = section.Parameters[ServiceBusConnectionStringParameter]; 68 | if (!string.IsNullOrWhiteSpace(parameter?.Value)) 69 | { 70 | ServiceBusConnectionString = parameter.Value; 71 | } 72 | else 73 | { 74 | throw new ArgumentException( 75 | string.Format(ParameterCannotBeNullFormat, ServiceBusConnectionStringParameter), 76 | ServiceBusConnectionStringParameter); 77 | } 78 | 79 | // Read the EventHubName setting from the Settings.xml file 80 | parameter = section.Parameters[EventHubNameParameter]; 81 | if (!string.IsNullOrWhiteSpace(parameter?.Value)) 82 | { 83 | EventHubName = parameter.Value; 84 | } 85 | else 86 | { 87 | throw new ArgumentException(string.Format(ParameterCannotBeNullFormat, EventHubNameParameter), 88 | EventHubNameParameter); 89 | } 90 | 91 | // Read the QueueLength setting from the Settings.xml file 92 | parameter = section.Parameters[QueueLengthParameter]; 93 | if (!string.IsNullOrWhiteSpace(parameter?.Value)) 94 | { 95 | QueueLength = DefaultQueueLength; 96 | int queueLength; 97 | if (int.TryParse(parameter.Value, out queueLength)) 98 | { 99 | QueueLength = queueLength; 100 | } 101 | } 102 | else 103 | { 104 | throw new ArgumentException(string.Format(ParameterCannotBeNullFormat, QueueLengthParameter), 105 | QueueLengthParameter); 106 | } 107 | } 108 | #endregion 109 | 110 | #region Public Properties 111 | /// 112 | /// Gets or sets the service bus connection string 113 | /// 114 | public string ServiceBusConnectionString { get; private set; } 115 | 116 | /// 117 | /// Gets or sets the event hub name 118 | /// 119 | public string EventHubName { get; private set; } 120 | 121 | /// 122 | /// Gets or sets the queue length 123 | /// 124 | public int QueueLength { get; private set; } 125 | #endregion 126 | } 127 | } -------------------------------------------------------------------------------- /DeviceActorService/PackageRoot/Config/Settings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 |
4 | 5 | 6 |
7 |
8 | 9 |
10 |
11 | 12 | 13 | 14 |
15 |
-------------------------------------------------------------------------------- /DeviceActorService/PackageRoot/ServiceManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | DeviceActorService.exe 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /DeviceActorService/Program.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Threading; 22 | using Microsoft.ApplicationInsights; 23 | using Microsoft.ServiceFabric.Actors.Runtime; 24 | 25 | #endregion 26 | 27 | namespace Microsoft.AzureCat.Samples.DeviceActorService 28 | { 29 | internal static class Program 30 | { 31 | /// 32 | /// Application Insights Telemetry Client static field 33 | /// 34 | internal static TelemetryClient TelemetryClient; 35 | 36 | /// 37 | /// This is the entry point of the service host process. 38 | /// 39 | private static void Main() 40 | { 41 | try 42 | { 43 | TelemetryClient = new TelemetryClient(); 44 | } 45 | catch (Exception) 46 | { 47 | // ignored 48 | } 49 | try 50 | { 51 | // Create default garbage collection settings for all the actor types 52 | var actorGarbageCollectionSettings = new ActorGarbageCollectionSettings(300, 60); 53 | 54 | // This line registers your actor class with the Fabric Runtime. 55 | // The contents of your ServiceManifest.xml and ApplicationManifest.xml files 56 | // are automatically populated when you build this project. 57 | // For more information, see http://aka.ms/servicefabricactorsplatform 58 | 59 | ActorRuntime.RegisterActorAsync( 60 | (context, actorType) => new DeviceActorService(context, actorType, () => new DeviceActor(), null, new ActorServiceSettings 61 | { 62 | ActorGarbageCollectionSettings = actorGarbageCollectionSettings 63 | })).GetAwaiter().GetResult(); 64 | 65 | Thread.Sleep(Timeout.Infinite); 66 | } 67 | catch (Exception e) 68 | { 69 | TelemetryClient.TrackException(e); 70 | ActorEventSource.Current.ActorHostInitializationFailed(e); 71 | throw; 72 | } 73 | finally 74 | { 75 | TelemetryClient.Flush(); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /DeviceActorService/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("DeviceActorService")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("DeviceActorService")] 12 | [assembly: AssemblyCopyright("Copyright © 2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("a8feee4e-6854-4ee0-a9fb-899c81740191")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /DeviceActorService/Service References/Application Insights/ConnectedService.json: -------------------------------------------------------------------------------- 1 | { 2 | "ProviderId": "Microsoft.ApplicationInsights.ConnectedService.ConnectedServiceProvider", 3 | "Version": "4.1.60107.3", 4 | "GettingStartedDocument": { 5 | "Uri": "http://go.microsoft.com/fwlink/?LinkID=613407" 6 | } 7 | } -------------------------------------------------------------------------------- /DeviceActorService/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /DeviceManagementWebService/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /DeviceManagementWebService/App_Start/BrowserJsonFormatter.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | using System; 20 | using System.Net.Http.Formatting; 21 | using System.Net.Http.Headers; 22 | using Newtonsoft.Json; 23 | #endregion 24 | 25 | namespace Microsoft.AzureCat.Samples.DeviceManagementWebService 26 | { 27 | public class BrowserJsonFormatter : JsonMediaTypeFormatter 28 | { 29 | public BrowserJsonFormatter() 30 | { 31 | SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html")); 32 | SerializerSettings.Formatting = Formatting.Indented; 33 | } 34 | 35 | public override void SetDefaultContentHeaders(Type type, HttpContentHeaders headers, MediaTypeHeaderValue mediaType) 36 | { 37 | base.SetDefaultContentHeaders(type, headers, mediaType); 38 | headers.ContentType = new MediaTypeHeaderValue("application/json"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /DeviceManagementWebService/Controllers/DeviceController.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directices 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.Linq; 23 | using System.Threading.Tasks; 24 | using System.Web.Http; 25 | using Microsoft.AzureCat.Samples.DeviceActorService.Interfaces; 26 | using Microsoft.AzureCat.Samples.PayloadEntities; 27 | using Microsoft.ServiceFabric.Actors; 28 | using Microsoft.ServiceFabric.Actors.Client; 29 | 30 | #endregion 31 | 32 | namespace Microsoft.AzureCat.Samples.DeviceManagementWebService 33 | { 34 | public class DeviceController : ApiController 35 | { 36 | #region Private Static Fields 37 | private static readonly Dictionary actorProxyDictionary = new Dictionary(); 38 | #endregion 39 | 40 | #region Public Methods 41 | [HttpGet] 42 | public async Task GetDevice(long id) 43 | { 44 | try 45 | { 46 | var proxy = GetActorProxy(id); 47 | if (proxy != null) 48 | { 49 | return await proxy.GetData(); 50 | } 51 | } 52 | catch (AggregateException ex) 53 | { 54 | if (ex.InnerExceptions?.Count > 0) 55 | { 56 | foreach (var exception in ex.InnerExceptions) 57 | { 58 | ServiceEventSource.Current.Message(exception.Message); 59 | } 60 | } 61 | } 62 | catch (Exception ex) 63 | { 64 | ServiceEventSource.Current.Message(ex.Message); 65 | } 66 | return null; 67 | } 68 | 69 | [HttpPost] 70 | [Route("api/devices/get")] 71 | public async Task> GetDevices(IEnumerable ids) 72 | { 73 | try 74 | { 75 | var enumerable = ids as IList ?? ids.ToList(); 76 | if (ids == null || !enumerable.Any()) 77 | { 78 | return null; 79 | } 80 | var deviceList = new List(); 81 | foreach (var id in enumerable) 82 | { 83 | var proxy = GetActorProxy(id); 84 | if (proxy != null) 85 | { 86 | deviceList.Add(await proxy.GetData()); 87 | } 88 | } 89 | return deviceList; 90 | } 91 | catch (AggregateException ex) 92 | { 93 | if (ex.InnerExceptions?.Count > 0) 94 | { 95 | foreach (var exception in ex.InnerExceptions) 96 | { 97 | ServiceEventSource.Current.Message(exception.Message); 98 | } 99 | } 100 | } 101 | catch (Exception ex) 102 | { 103 | ServiceEventSource.Current.Message(ex.Message); 104 | } 105 | return null; 106 | } 107 | 108 | [HttpPost] 109 | public async Task SetDevice(Device device) 110 | { 111 | try 112 | { 113 | var proxy = GetActorProxy(device.DeviceId); 114 | if (proxy != null) 115 | { 116 | await proxy.SetData(device); 117 | } 118 | } 119 | catch (AggregateException ex) 120 | { 121 | if (ex.InnerExceptions?.Count > 0) 122 | { 123 | foreach (var exception in ex.InnerExceptions) 124 | { 125 | ServiceEventSource.Current.Message(exception.Message); 126 | } 127 | } 128 | } 129 | catch (Exception ex) 130 | { 131 | ServiceEventSource.Current.Message(ex.Message); 132 | } 133 | } 134 | 135 | [HttpPost] 136 | [Route("api/devices/set")] 137 | public async Task SetDevices(IEnumerable devices) 138 | { 139 | try 140 | { 141 | var enumerable = devices as IList ?? devices.ToList(); 142 | if (devices == null || !enumerable.Any()) 143 | { 144 | return; 145 | } 146 | foreach (var device in enumerable) 147 | { 148 | var proxy = GetActorProxy(device.DeviceId); 149 | if (proxy != null) 150 | { 151 | await proxy.SetData(device); 152 | } 153 | } 154 | } 155 | catch (AggregateException ex) 156 | { 157 | if (ex.InnerExceptions?.Count > 0) 158 | { 159 | foreach (var exception in ex.InnerExceptions) 160 | { 161 | ServiceEventSource.Current.Message(exception.Message); 162 | } 163 | } 164 | } 165 | catch (Exception ex) 166 | { 167 | ServiceEventSource.Current.Message(ex.Message); 168 | } 169 | } 170 | #endregion 171 | 172 | #region Private Static Methods 173 | private IDeviceActor GetActorProxy(long deviceId) 174 | { 175 | lock (actorProxyDictionary) 176 | { 177 | if (actorProxyDictionary.ContainsKey(deviceId)) 178 | { 179 | return actorProxyDictionary[deviceId]; 180 | } 181 | actorProxyDictionary[deviceId] = ActorProxy.Create(new ActorId($"device{deviceId}"), 182 | new Uri(OwinCommunicationListener.DeviceActorServiceUri)); 183 | return actorProxyDictionary[deviceId]; 184 | } 185 | } 186 | #endregion 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /DeviceManagementWebService/DeviceManagementWebService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Fabric; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Microsoft.ServiceFabric.Services.Communication.Runtime; 7 | using Microsoft.ServiceFabric.Services.Runtime; 8 | 9 | namespace Microsoft.AzureCat.Samples.DeviceManagementWebService 10 | { 11 | /// 12 | /// The FabricRuntime creates an instance of this class for each service type instance. 13 | /// 14 | internal sealed class DeviceManagementWebService : StatelessService 15 | { 16 | #region Public Constructor 17 | public DeviceManagementWebService(StatelessServiceContext context) 18 | : base(context) 19 | { } 20 | #endregion 21 | 22 | #region StatelessService Protected Methods 23 | /// 24 | /// Optional override to create listeners (like tcp, http) for this service instance. 25 | /// 26 | /// The collection of listeners. 27 | protected override IEnumerable CreateServiceInstanceListeners() 28 | { 29 | return new[] 30 | { 31 | new ServiceInstanceListener(s => new OwinCommunicationListener("devicemanagement", new Startup(), s)) 32 | }; 33 | } 34 | 35 | /// 36 | /// This is the main entry point for your service instance. 37 | /// 38 | /// Canceled when Service Fabric terminates this instance. 39 | protected override async Task RunAsync(CancellationToken cancelServiceInstance) 40 | { 41 | // This service instance continues processing until the instance is terminated. 42 | while (!cancelServiceInstance.IsCancellationRequested) 43 | { 44 | // Pause for 1 second before continue processing. 45 | await Task.Delay(TimeSpan.FromSeconds(1), cancelServiceInstance); 46 | } 47 | } 48 | #endregion 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /DeviceManagementWebService/IOwinAppBuilder.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | using Owin; 20 | #endregion 21 | 22 | namespace Microsoft.AzureCat.Samples.DeviceManagementWebService 23 | { 24 | public interface IOwinAppBuilder 25 | { 26 | void Configuration(IAppBuilder appBuilder); 27 | } 28 | } -------------------------------------------------------------------------------- /DeviceManagementWebService/OwinCommunicationListener.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Fabric; 22 | using System.Globalization; 23 | using System.Threading; 24 | using System.Threading.Tasks; 25 | using Microsoft.Owin.Hosting; 26 | using Microsoft.ServiceFabric.Services.Communication.Runtime; 27 | using System.Linq; 28 | 29 | #endregion 30 | 31 | namespace Microsoft.AzureCat.Samples.DeviceManagementWebService 32 | { 33 | public class OwinCommunicationListener : ICommunicationListener 34 | { 35 | #region Private Constants 36 | //************************************ 37 | // Parameters 38 | //************************************ 39 | private const string ConfigurationPackage = "Config"; 40 | private const string ConfigurationSection = "DeviceManagementWebServiceConfig"; 41 | private const string DeviceActorServiceUriParameter = "DeviceActorServiceUri"; 42 | #endregion 43 | 44 | #region Private Fields 45 | private readonly IOwinAppBuilder startup; 46 | private readonly string appRoot; 47 | private readonly StatelessServiceContext context; 48 | private IDisposable serverHandle; 49 | private string listeningAddress; 50 | #endregion 51 | 52 | #region Public Constructor 53 | public OwinCommunicationListener(string appRoot, IOwinAppBuilder startup, StatelessServiceContext context) 54 | { 55 | this.startup = startup; 56 | this.appRoot = appRoot; 57 | this.context = context; 58 | } 59 | #endregion 60 | 61 | #region Public Static Properties 62 | public static string DeviceActorServiceUri { get; private set; } 63 | #endregion 64 | 65 | #region ICommunicationListener Methods 66 | public Task OpenAsync(CancellationToken cancellationToken) 67 | { 68 | try 69 | { 70 | // Read settings from the DeviceActorServiceConfig section in the Settings.xml file 71 | var activationContext = context.CodePackageActivationContext; 72 | var config = activationContext.GetConfigurationPackageObject(ConfigurationPackage); 73 | var section = config.Settings.Sections[ConfigurationSection]; 74 | 75 | // Check if a parameter called DeviceActorServiceUri exists in the DeviceActorServiceConfig config section 76 | if (section.Parameters.Any(p => string.Compare(p.Name, 77 | DeviceActorServiceUriParameter, 78 | StringComparison.InvariantCultureIgnoreCase) == 0)) 79 | { 80 | var parameter = section.Parameters[DeviceActorServiceUriParameter]; 81 | DeviceActorServiceUri = !string.IsNullOrWhiteSpace(parameter?.Value) ? 82 | parameter.Value : 83 | // By default, the current service assumes that if no URI is explicitly defined for the actor service 84 | // in the Setting.xml file, the latter is hosted in the same Service Fabric application. 85 | $"fabric:/{context.ServiceName.Segments[1]}DeviceActorService"; 86 | } 87 | else 88 | { 89 | // By default, the current service assumes that if no URI is explicitly defined for the actor service 90 | // in the Setting.xml file, the latter is hosted in the same Service Fabric application. 91 | DeviceActorServiceUri = $"fabric:/{context.ServiceName.Segments[1]}DeviceActorService"; 92 | } 93 | 94 | var serviceEndpoint = context.CodePackageActivationContext.GetEndpoint("ServiceEndpoint"); 95 | var port = serviceEndpoint.Port; 96 | 97 | listeningAddress = String.Format( 98 | CultureInfo.InvariantCulture, 99 | "http://+:{0}/{1}", 100 | port, 101 | String.IsNullOrWhiteSpace(appRoot) 102 | ? String.Empty 103 | : appRoot.TrimEnd('/') + '/'); 104 | 105 | serverHandle = WebApp.Start(listeningAddress, appBuilder => startup.Configuration(appBuilder)); 106 | string publishAddress = listeningAddress.Replace("+", FabricRuntime.GetNodeContext().IPAddressOrFQDN); 107 | 108 | ServiceEventSource.Current.Message($"Listening on {publishAddress}"); 109 | 110 | return Task.FromResult(publishAddress); 111 | } 112 | catch (Exception ex) 113 | { 114 | ServiceEventSource.Current.Message(ex.Message); 115 | throw; 116 | } 117 | } 118 | 119 | public Task CloseAsync(CancellationToken cancellationToken) 120 | { 121 | ServiceEventSource.Current.Message("Close"); 122 | 123 | StopWebServer(); 124 | 125 | return Task.FromResult(true); 126 | } 127 | 128 | public void Abort() 129 | { 130 | ServiceEventSource.Current.Message("Abort"); 131 | 132 | StopWebServer(); 133 | } 134 | #endregion 135 | 136 | #region Private Methods 137 | private void StopWebServer() 138 | { 139 | if (serverHandle == null) 140 | { 141 | return; 142 | } 143 | try 144 | { 145 | serverHandle.Dispose(); 146 | } 147 | catch (ObjectDisposedException) 148 | { 149 | // no-op 150 | } 151 | } 152 | #endregion 153 | } 154 | } -------------------------------------------------------------------------------- /DeviceManagementWebService/PackageRoot/Config/Settings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
5 | 6 |
7 |
8 | -------------------------------------------------------------------------------- /DeviceManagementWebService/PackageRoot/ServiceManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | DeviceManagementWebService.exe 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /DeviceManagementWebService/Program.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | using System; 20 | using System.Diagnostics; 21 | using System.Threading; 22 | using Microsoft.ServiceFabric.Services.Runtime; 23 | 24 | #endregion 25 | 26 | namespace Microsoft.AzureCat.Samples.DeviceManagementWebService 27 | { 28 | internal static class Program 29 | { 30 | /// 31 | /// This is the entry point of the service host process. 32 | /// 33 | private static void Main() 34 | { 35 | try 36 | { 37 | // The ServiceManifest.XML file defines one or more service type names. 38 | // Registering a service maps a service type name to a .NET type. 39 | // When Service Fabric creates an instance of this service type, 40 | // an instance of the class is created in this host process. 41 | 42 | ServiceRuntime.RegisterServiceAsync("DeviceManagementWebServiceType", 43 | context => new DeviceManagementWebService(context)).GetAwaiter().GetResult(); 44 | 45 | ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(DeviceManagementWebService).Name); 46 | 47 | // Prevents this host process from terminating so services keep running. 48 | Thread.Sleep(Timeout.Infinite); 49 | } 50 | catch (Exception e) 51 | { 52 | ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); 53 | throw; 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /DeviceManagementWebService/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("DeviceManagementWebService")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("DeviceManagementWebService")] 12 | [assembly: AssemblyCopyright("Copyright © 2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("b527fd03-1472-48bb-a2d2-50017caabce3")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /DeviceManagementWebService/Startup.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System.Web.Http; 21 | using Owin; 22 | 23 | #endregion 24 | 25 | namespace Microsoft.AzureCat.Samples.DeviceManagementWebService 26 | { 27 | public class Startup : IOwinAppBuilder 28 | { 29 | public void Configuration(IAppBuilder app) 30 | { 31 | var httpConfiguration = new HttpConfiguration(); 32 | httpConfiguration.MapHttpAttributeRoutes(); 33 | httpConfiguration.Routes.MapHttpRoute(name: "DefaultApi", 34 | routeTemplate: "api/{controller}/{id}", 35 | defaults: new { id = RouteParameter.Optional }); 36 | httpConfiguration.Formatters.Add(new BrowserJsonFormatter()); 37 | app.UseWebApi(httpConfiguration); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /DeviceManagementWebService/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /DeviceSimulator.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator.lnk -------------------------------------------------------------------------------- /DeviceSimulator/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 25 | 27 | 28 | 29 | 31 | 33 | 35 | 37 | 39 | 40 | 41 | 43 | 45 | 47 | 49 | 51 | 53 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /DeviceSimulator/Controls/HeaderPanel.Designer.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace Microsoft.AzureCat.Samples.DeviceSimulator 4 | { 5 | partial class HeaderPanel 6 | { 7 | /// 8 | /// Required designer variable. 9 | /// 10 | private IContainer components = null; 11 | 12 | /// 13 | /// Clean up any resources being used. 14 | /// 15 | /// true if managed resources should be disposed; otherwise, false. 16 | protected override void Dispose(bool disposing) 17 | { 18 | if (disposing && (components != null)) 19 | { 20 | components.Dispose(); 21 | } 22 | base.Dispose(disposing); 23 | } 24 | 25 | #region Component Designer generated code 26 | 27 | /// 28 | /// Required method for Designer support - do not modify 29 | /// the contents of this method with the code editor. 30 | /// 31 | private void InitializeComponent() 32 | { 33 | this.SuspendLayout(); 34 | // 35 | // OutlookPanelEx 36 | // 37 | this.BackColor = System.Drawing.SystemColors.ControlLightLight; 38 | this.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); 39 | this.Name = "OutlookPanelEx"; 40 | this.Size = new System.Drawing.Size(224, 172); 41 | this.Paint += new System.Windows.Forms.PaintEventHandler(this.OutlookPanelEx_Paint); 42 | this.ResumeLayout(false); 43 | 44 | } 45 | 46 | #endregion 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /DeviceSimulator/Controls/HeaderPanel.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Controls/HeaderPanel.cs -------------------------------------------------------------------------------- /DeviceSimulator/Controls/HeaderPanel.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /DeviceSimulator/Controls/NumericTextBox.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Business Platform Division Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on my personal 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2011 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Globalization; 22 | using System.Windows.Forms; 23 | 24 | #endregion 25 | 26 | namespace Microsoft.AzureCat.Samples.DeviceSimulator 27 | { 28 | public class NumericTextBox : TextBox 29 | { 30 | #region Private Fields 31 | private bool allowSpace; 32 | #endregion 33 | 34 | #region Protected Methods 35 | // Restricts the entry of characters to digits (including hex), the negative sign, 36 | // the decimal point, and editing keystrokes (backspace). 37 | protected override void OnKeyPress(KeyPressEventArgs e) 38 | { 39 | base.OnKeyPress(e); 40 | 41 | var numberFormatInfo = CultureInfo.CurrentCulture.NumberFormat; 42 | var decimalSeparator = numberFormatInfo.NumberDecimalSeparator; 43 | var groupSeparator = numberFormatInfo.NumberGroupSeparator; 44 | var negativeSign = numberFormatInfo.NegativeSign; 45 | 46 | var keyInput = e.KeyChar.ToString(CultureInfo.InvariantCulture); 47 | 48 | if (Char.IsDigit(e.KeyChar)) 49 | { 50 | // Digits are OK 51 | } 52 | else if (keyInput.Equals(decimalSeparator) || keyInput.Equals(groupSeparator) || 53 | keyInput.Equals(negativeSign)) 54 | { 55 | // Decimal separator is OK 56 | } 57 | else if (e.KeyChar == '\b') 58 | { 59 | // Backspace key is OK 60 | } 61 | // else if ((ModifierKeys & (Keys.Control | Keys.Alt)) != 0) 62 | // { 63 | // // Let the edit control handle control and alt key combinations 64 | // } 65 | else if (allowSpace && e.KeyChar == ' ') 66 | { 67 | 68 | } 69 | else 70 | { 71 | // Swallow this invalid key and beep 72 | e.Handled = true; 73 | } 74 | } 75 | #endregion 76 | 77 | #region Public Properties 78 | public int IntegerValue 79 | { 80 | get { return Int32.Parse(Text); } 81 | } 82 | 83 | public decimal DecimalValue 84 | { 85 | get { return Decimal.Parse(Text); } 86 | } 87 | 88 | public bool AllowSpace 89 | { 90 | set { allowSpace = value; } 91 | 92 | get { return allowSpace; } 93 | } 94 | #endregion 95 | } 96 | } -------------------------------------------------------------------------------- /DeviceSimulator/Controls/TrackBar.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Controls/TrackBar.cs -------------------------------------------------------------------------------- /DeviceSimulator/Controls/TrackBar.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | text/microsoft-resx 32 | 33 | 34 | 1.0.0.0 35 | 36 | 37 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 38 | 39 | 40 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 41 | 42 | 43 | -------------------------------------------------------------------------------- /DeviceSimulator/Controls/TrackBarDesigner.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Controls/TrackBarDesigner.cs -------------------------------------------------------------------------------- /DeviceSimulator/Helpers/CustomColorHelper.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Helpers/CustomColorHelper.cs -------------------------------------------------------------------------------- /DeviceSimulator/Helpers/CustomStyleHelper.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Helpers/CustomStyleHelper.cs -------------------------------------------------------------------------------- /DeviceSimulator/Icons/AzureLogo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Icons/AzureLogo.ico -------------------------------------------------------------------------------- /DeviceSimulator/Icons/Tool.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Icons/Tool.ico -------------------------------------------------------------------------------- /DeviceSimulator/Icons/WindowsAzureLogo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Icons/WindowsAzureLogo.ico -------------------------------------------------------------------------------- /DeviceSimulator/Images/AzureLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Images/AzureLogo.png -------------------------------------------------------------------------------- /DeviceSimulator/Images/SmallDocument.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Images/SmallDocument.png -------------------------------------------------------------------------------- /DeviceSimulator/Images/SmallWorld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Images/SmallWorld.png -------------------------------------------------------------------------------- /DeviceSimulator/Images/Warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Images/Warning.png -------------------------------------------------------------------------------- /DeviceSimulator/Images/WhiteLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/DeviceSimulator/Images/WhiteLogo.png -------------------------------------------------------------------------------- /DeviceSimulator/Program.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Windows.Forms; 22 | 23 | #endregion 24 | 25 | namespace Microsoft.AzureCat.Samples.DeviceSimulator 26 | { 27 | static class Program 28 | { 29 | /// 30 | /// The main entry point for the application. 31 | /// 32 | [STAThread] 33 | static void Main() 34 | { 35 | Application.EnableVisualStyles(); 36 | Application.SetCompatibleTextRenderingDefault(false); 37 | Application.Run(new MainForm()); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /DeviceSimulator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("DeviceSimulator")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("DeviceSimulator")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("25791060-8870-4d2d-a58a-d4cb91105e88")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /DeviceSimulator/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.0 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System.CodeDom.Compiler; 12 | using System.ComponentModel; 13 | using System.Diagnostics; 14 | using System.Diagnostics.CodeAnalysis; 15 | using System.Drawing; 16 | using System.Globalization; 17 | using System.Resources; 18 | using System.Runtime.CompilerServices; 19 | 20 | namespace Microsoft.AzureCat.Samples.DeviceSimulator.Properties { 21 | /// 22 | /// A strongly-typed resource class, for looking up localized strings, etc. 23 | /// 24 | // This class was auto-generated by the StronglyTypedResourceBuilder 25 | // class via a tool like ResGen or Visual Studio. 26 | // To add or remove a member, edit your .ResX file then rerun ResGen 27 | // with the /str option, or rebuild your VS project. 28 | [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 29 | [DebuggerNonUserCode()] 30 | [CompilerGenerated()] 31 | internal class Resources { 32 | 33 | private static ResourceManager resourceMan; 34 | 35 | private static CultureInfo resourceCulture; 36 | 37 | [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 38 | internal Resources() { 39 | } 40 | 41 | /// 42 | /// Returns the cached ResourceManager instance used by this class. 43 | /// 44 | [EditorBrowsable(EditorBrowsableState.Advanced)] 45 | internal static ResourceManager ResourceManager { 46 | get { 47 | if (ReferenceEquals(resourceMan, null)) { 48 | ResourceManager temp = new ResourceManager("Microsoft.AzureCat.Samples.DeviceSimulator.Properties.Resources", typeof(Resources).Assembly); 49 | resourceMan = temp; 50 | } 51 | return resourceMan; 52 | } 53 | } 54 | 55 | /// 56 | /// Overrides the current thread's CurrentUICulture property for all 57 | /// resource lookups using this strongly typed resource class. 58 | /// 59 | [EditorBrowsable(EditorBrowsableState.Advanced)] 60 | internal static CultureInfo Culture { 61 | get { 62 | return resourceCulture; 63 | } 64 | set { 65 | resourceCulture = value; 66 | } 67 | } 68 | 69 | /// 70 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 71 | /// 72 | internal static Icon AzureLogo { 73 | get { 74 | object obj = ResourceManager.GetObject("AzureLogo", resourceCulture); 75 | return ((Icon)(obj)); 76 | } 77 | } 78 | 79 | /// 80 | /// Looks up a localized resource of type System.Drawing.Bitmap. 81 | /// 82 | internal static Bitmap AzureLogo1 { 83 | get { 84 | object obj = ResourceManager.GetObject("AzureLogo1", resourceCulture); 85 | return ((Bitmap)(obj)); 86 | } 87 | } 88 | 89 | /// 90 | /// Looks up a localized resource of type System.Drawing.Bitmap. 91 | /// 92 | internal static Bitmap SmallDocument { 93 | get { 94 | object obj = ResourceManager.GetObject("SmallDocument", resourceCulture); 95 | return ((Bitmap)(obj)); 96 | } 97 | } 98 | 99 | /// 100 | /// Looks up a localized resource of type System.Drawing.Bitmap. 101 | /// 102 | internal static Bitmap SmallWorld { 103 | get { 104 | object obj = ResourceManager.GetObject("SmallWorld", resourceCulture); 105 | return ((Bitmap)(obj)); 106 | } 107 | } 108 | 109 | /// 110 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 111 | /// 112 | internal static Icon Tool { 113 | get { 114 | object obj = ResourceManager.GetObject("Tool", resourceCulture); 115 | return ((Icon)(obj)); 116 | } 117 | } 118 | 119 | /// 120 | /// Looks up a localized resource of type System.Drawing.Bitmap. 121 | /// 122 | internal static Bitmap Warning { 123 | get { 124 | object obj = ResourceManager.GetObject("Warning", resourceCulture); 125 | return ((Bitmap)(obj)); 126 | } 127 | } 128 | 129 | /// 130 | /// Looks up a localized resource of type System.Drawing.Bitmap. 131 | /// 132 | internal static Bitmap WhiteLogo { 133 | get { 134 | object obj = ResourceManager.GetObject("WhiteLogo", resourceCulture); 135 | return ((Bitmap)(obj)); 136 | } 137 | } 138 | 139 | /// 140 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 141 | /// 142 | internal static Icon WindowsAzureLogo { 143 | get { 144 | object obj = ResourceManager.GetObject("WindowsAzureLogo", resourceCulture); 145 | return ((Icon)(obj)); 146 | } 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /DeviceSimulator/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.0 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System.CodeDom.Compiler; 12 | using System.Configuration; 13 | using System.Runtime.CompilerServices; 14 | 15 | namespace Microsoft.AzureCat.Samples.DeviceSimulator.Properties { 16 | 17 | 18 | [CompilerGenerated()] 19 | [GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 20 | internal sealed partial class Settings : ApplicationSettingsBase { 21 | 22 | private static Settings defaultInstance = ((Settings)(Synchronized(new Settings()))); 23 | 24 | public static Settings Default { 25 | get { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DeviceSimulator/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DeviceSimulator/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Entities/Alert.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using Newtonsoft.Json; 22 | 23 | #endregion 24 | 25 | namespace Microsoft.AzureCat.Samples.PayloadEntities 26 | { 27 | public class Alert : Device 28 | { 29 | /// 30 | /// Gets or sets the device value. 31 | /// 32 | [JsonProperty(PropertyName = "value")] 33 | public double Value { get; set; } 34 | 35 | /// 36 | /// Gets or sets the status. 37 | /// 38 | [JsonProperty(PropertyName = "status")] 39 | public string Status { get; set; } 40 | 41 | /// 42 | /// Gets or sets the timestamp. 43 | /// 44 | [JsonProperty(PropertyName = "timestamp")] 45 | public DateTime Timestamp { get; set; } 46 | } 47 | } -------------------------------------------------------------------------------- /Entities/Device.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using Newtonsoft.Json; 21 | 22 | #endregion 23 | 24 | namespace Microsoft.AzureCat.Samples.PayloadEntities 25 | { 26 | public class Device 27 | { 28 | /// 29 | /// Gets or sets the device id. 30 | /// 31 | [JsonProperty(PropertyName = "deviceId", Order = 1)] 32 | public long DeviceId { get; set; } 33 | 34 | /// 35 | /// Gets or sets the device name. 36 | /// 37 | [JsonProperty(PropertyName = "name", Order = 2)] 38 | public string Name { get; set; } 39 | 40 | /// 41 | /// Gets or sets the device min threshold. 42 | /// 43 | [JsonProperty(PropertyName = "minThreshold", Order = 3)] 44 | public int MinThreshold { get; set; } 45 | 46 | /// 47 | /// Gets or sets the device max threshold. 48 | /// 49 | [JsonProperty(PropertyName = "maxThreshold", Order = 4)] 50 | public int MaxThreshold { get; set; } 51 | 52 | /// 53 | /// Gets or sets the device model. 54 | /// 55 | [JsonProperty(PropertyName = "model", Order = 5)] 56 | public string Model { get; set; } 57 | 58 | /// 59 | /// Gets or sets the device type. 60 | /// 61 | [JsonProperty(PropertyName = "type", Order = 6)] 62 | public string Type { get; set; } 63 | 64 | /// 65 | /// Gets or sets the device manufacturer. 66 | /// 67 | [JsonProperty(PropertyName = "manufacturer", Order = 7)] 68 | public string Manufacturer { get; set; } 69 | 70 | /// 71 | /// Gets or sets the device dity. 72 | /// 73 | [JsonProperty(PropertyName = "city", Order = 8)] 74 | public string City { get; set; } 75 | 76 | /// 77 | /// Gets or sets the device country. 78 | /// 79 | [JsonProperty(PropertyName = "country", Order = 9)] 80 | public string Country { get; set; } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Entities/Payload.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using Newtonsoft.Json; 22 | 23 | #endregion 24 | 25 | namespace Microsoft.AzureCat.Samples.PayloadEntities 26 | { 27 | public class Payload 28 | { 29 | /// 30 | /// Gets or sets the device id. 31 | /// 32 | [JsonProperty(PropertyName = "deviceId", Order = 1)] 33 | public long DeviceId { get; set; } 34 | 35 | /// 36 | /// Gets or sets the device name. 37 | /// 38 | [JsonProperty(PropertyName = "name", Order = 2)] 39 | public string Name { get; set; } 40 | 41 | /// 42 | /// Gets or sets the device value. 43 | /// 44 | [JsonProperty(PropertyName = "value", Order = 3)] 45 | public double Value { get; set; } 46 | 47 | /// 48 | /// Gets or sets the status. 49 | /// 50 | [JsonProperty(PropertyName = "status", Order = 4)] 51 | public string Status { get; set; } 52 | 53 | /// 54 | /// Gets or sets the timestamp. 55 | /// 56 | [JsonProperty(PropertyName = "timestamp", Order = 5)] 57 | public DateTime Timestamp { get; set; } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Entities/PayloadEntities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {AA413FD4-FD2B-4B29-864C-E42915767176} 8 | Library 9 | Properties 10 | Microsoft.AzureCat.Samples.PayloadEntities 11 | Microsoft.AzureCat.Samples.PayloadEntities 12 | v4.5 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | AnyCPU 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\packages\Microsoft.Data.Edm.5.7.0\lib\net40\Microsoft.Data.Edm.dll 37 | True 38 | 39 | 40 | ..\packages\Microsoft.Data.OData.5.7.0\lib\net40\Microsoft.Data.OData.dll 41 | True 42 | 43 | 44 | ..\packages\Microsoft.Data.Services.Client.5.7.0\lib\net40\Microsoft.Data.Services.Client.dll 45 | True 46 | 47 | 48 | ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll 49 | True 50 | 51 | 52 | 53 | 54 | 55 | 56 | ..\packages\System.Spatial.5.7.0\lib\net40\System.Spatial.dll 57 | True 58 | 59 | 60 | ..\packages\Microsoft.AspNet.Cors.5.2.3\lib\net45\System.Web.Cors.dll 61 | True 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 88 | -------------------------------------------------------------------------------- /Entities/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Entities")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Entities")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("aa413fd4-fd2b-4b29-864c-e42915767176")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Entities/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Entities/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /EventProcessorHostService/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /EventProcessorHostService/EventProcessor.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.Linq; 23 | using System.Text; 24 | using System.Threading.Tasks; 25 | using Microsoft.AzureCat.Samples.DeviceActorService.Interfaces; 26 | using Microsoft.AzureCat.Samples.PayloadEntities; 27 | using Microsoft.ServiceBus.Messaging; 28 | using Microsoft.ServiceFabric.Actors; 29 | using Microsoft.ServiceFabric.Actors.Client; 30 | using Newtonsoft.Json; 31 | 32 | #endregion 33 | 34 | namespace Microsoft.AzureCat.Samples.EventProcessorHostService 35 | { 36 | public class EventProcessor : IEventProcessor 37 | { 38 | #region Private Constants 39 | private const string DeviceActorServiceUriCannotBeNull = "DeviceActorServiceUri setting cannot be null"; 40 | #endregion 41 | 42 | #region Private Fields 43 | private readonly Uri serviceUri; 44 | #endregion 45 | 46 | #region Private Static Fields 47 | private static readonly Dictionary actorProxyDictionary = new Dictionary(); 48 | #endregion 49 | 50 | #region Public Constructors 51 | public EventProcessor(string parameter) 52 | { 53 | if (string.IsNullOrWhiteSpace(parameter)) 54 | { 55 | throw new ArgumentNullException(DeviceActorServiceUriCannotBeNull); 56 | } 57 | serviceUri = new Uri(parameter); 58 | } 59 | #endregion 60 | 61 | #region IEventProcessor Methods 62 | public Task OpenAsync(PartitionContext context) 63 | { 64 | ServiceEventSource.Current.Message($"Lease acquired: EventHub=[{context.EventHubPath}] ConsumerGroup=[{context.ConsumerGroupName}] PartitionId=[{context.Lease.PartitionId}]"); 65 | return Task.FromResult(null); 66 | } 67 | 68 | public async Task ProcessEventsAsync(PartitionContext context, IEnumerable events) 69 | { 70 | try 71 | { 72 | if (events == null) 73 | { 74 | return; 75 | } 76 | var eventDataList = events as IList ?? events.ToList(); 77 | 78 | // Trace individual events 79 | foreach (var payload in eventDataList.Select(DeserializeEventData)) 80 | { 81 | // Invoke Actor 82 | if (payload == null) 83 | { 84 | continue; 85 | } 86 | 87 | // Invoke Device Actor 88 | var proxy = GetActorProxy(payload.DeviceId); 89 | if (proxy != null) 90 | { 91 | await proxy.ProcessEventAsync(payload); 92 | } 93 | } 94 | 95 | // Checkpoint 96 | await context.CheckpointAsync(); 97 | } 98 | catch (LeaseLostException ex) 99 | { 100 | // Trace Exception as message 101 | ServiceEventSource.Current.Message(ex.Message); 102 | } 103 | catch (AggregateException ex) 104 | { 105 | // Trace Exception 106 | foreach (var exception in ex.InnerExceptions) 107 | { 108 | ServiceEventSource.Current.Message(exception.Message); 109 | } 110 | } 111 | catch (Exception ex) 112 | { 113 | // Trace Exception 114 | ServiceEventSource.Current.Message(ex.Message); 115 | } 116 | } 117 | 118 | public async Task CloseAsync(PartitionContext context, CloseReason reason) 119 | { 120 | try 121 | { 122 | ServiceEventSource.Current.Message($"Lease lost: EventHub=[{context.EventHubPath}] ConsumerGroup=[{context.ConsumerGroupName}] PartitionId=[{context.Lease.PartitionId}]"); 123 | if (reason == CloseReason.Shutdown) 124 | { 125 | await context.CheckpointAsync(); 126 | } 127 | } 128 | catch (Exception ex) 129 | { 130 | // Trace Exception 131 | ServiceEventSource.Current.Message(ex.Message); 132 | } 133 | } 134 | #endregion 135 | 136 | #region Private Static Methods 137 | private static Payload DeserializeEventData(EventData eventData) 138 | { 139 | return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(eventData.GetBytes())); 140 | } 141 | 142 | private IDeviceActor GetActorProxy(long deviceId) 143 | { 144 | lock (actorProxyDictionary) 145 | { 146 | if (actorProxyDictionary.ContainsKey(deviceId)) 147 | { 148 | return actorProxyDictionary[deviceId]; 149 | } 150 | actorProxyDictionary[deviceId] = ActorProxy.Create(new ActorId($"device{deviceId}"), serviceUri); 151 | return actorProxyDictionary[deviceId]; 152 | } 153 | } 154 | #endregion 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /EventProcessorHostService/EventProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using Microsoft.ServiceBus.Messaging; 22 | 23 | #endregion 24 | 25 | namespace Microsoft.AzureCat.Samples.EventProcessorHostService 26 | { 27 | public class EventProcessorFactory : IEventProcessorFactory where T : class, IEventProcessor 28 | { 29 | #region Private Fields 30 | private readonly T instance; 31 | private readonly string parameter; 32 | #endregion 33 | 34 | #region Public Constructors 35 | public EventProcessorFactory() 36 | { 37 | parameter = null; 38 | } 39 | 40 | public EventProcessorFactory(string parameter) 41 | { 42 | this.parameter = parameter; 43 | } 44 | 45 | public EventProcessorFactory(T instance) 46 | { 47 | this.instance = instance; 48 | } 49 | #endregion 50 | 51 | #region IEventProcessorFactory Methods 52 | public IEventProcessor CreateEventProcessor(PartitionContext context) 53 | { 54 | return instance ?? Activator.CreateInstance(typeof(T), parameter) as T; 55 | } 56 | #endregion 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /EventProcessorHostService/EventProcessorHostService.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | 19 | #region Using Directives 20 | using System; 21 | using System.Collections.Generic; 22 | using System.Fabric; 23 | using System.Threading; 24 | using System.Threading.Tasks; 25 | using Microsoft.ServiceFabric.Services.Communication.Runtime; 26 | using Microsoft.ServiceFabric.Services.Runtime; 27 | #endregion 28 | 29 | namespace Microsoft.AzureCat.Samples.EventProcessorHostService 30 | { 31 | /// 32 | /// The FabricRuntime creates an instance of this class for each service type instance. 33 | /// 34 | internal sealed class EventProcessorHostService : StatelessService 35 | { 36 | #region Public Constructor 37 | public EventProcessorHostService(StatelessServiceContext context) 38 | : base(context) 39 | { } 40 | #endregion 41 | 42 | #region StatelessService Protected Methods 43 | /// 44 | /// Optional override to create listeners (like tcp, http) for this service instance. 45 | /// 46 | /// The collection of listeners. 47 | protected override IEnumerable CreateServiceInstanceListeners() 48 | { 49 | //return new ServiceInstanceListener[0]; 50 | return new[] 51 | { 52 | new ServiceInstanceListener(s => new EventProcessorHostListener(s)) 53 | }; 54 | } 55 | 56 | /// 57 | /// This is the main entry point for your service instance. 58 | /// 59 | /// Canceled when Service Fabric terminates this instance. 60 | protected override async Task RunAsync(CancellationToken cancelServiceInstance) 61 | { 62 | // This service instance continues processing until the instance is terminated. 63 | while (!cancelServiceInstance.IsCancellationRequested) 64 | { 65 | // Pause for 1 second before continue processing. 66 | await Task.Delay(TimeSpan.FromSeconds(1), cancelServiceInstance); 67 | } 68 | } 69 | #endregion 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /EventProcessorHostService/PackageRoot/Config/Settings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 | -------------------------------------------------------------------------------- /EventProcessorHostService/PackageRoot/ServiceManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | EventProcessorHostService.exe 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /EventProcessorHostService/Program.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | //======================================================================================= 3 | // Microsoft Azure Customer Advisory Team 4 | // 5 | // This sample is supplemental to the technical guidance published on the community 6 | // blog at http://blogs.msdn.com/b/paolos/. 7 | // 8 | // Author: Paolo Salvatori 9 | //======================================================================================= 10 | // Copyright © 2015 Microsoft Corporation. All rights reserved. 11 | // 12 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 13 | // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT. 15 | //======================================================================================= 16 | #endregion 17 | 18 | #region Using Directives 19 | 20 | using System; 21 | using System.Diagnostics; 22 | using System.Threading; 23 | using Microsoft.ServiceFabric.Services.Runtime; 24 | 25 | #endregion 26 | 27 | namespace Microsoft.AzureCat.Samples.EventProcessorHostService 28 | { 29 | internal static class Program 30 | { 31 | /// 32 | /// This is the entry point of the service host process. 33 | /// 34 | private static void Main() 35 | { 36 | try 37 | { 38 | // The ServiceManifest.XML file defines one or more service type names. 39 | // Registering a service maps a service type name to a .NET type. 40 | // When Service Fabric creates an instance of this service type, 41 | // an instance of the class is created in this host process. 42 | 43 | ServiceRuntime.RegisterServiceAsync("EventProcessorHostServiceType", 44 | context => new EventProcessorHostService(context)).GetAwaiter().GetResult(); 45 | 46 | ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(EventProcessorHostService).Name); 47 | 48 | // Prevents this host process from terminating so services keep running. 49 | Thread.Sleep(Timeout.Infinite); 50 | } 51 | catch (Exception e) 52 | { 53 | ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); 54 | throw; 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /EventProcessorHostService/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("EventProcessorHostService")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("EventProcessorHostService")] 12 | [assembly: AssemblyCopyright("Copyright © 2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("cf36d4ab-5668-487c-9981-2e55b89c21ff")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /EventProcessorHostService/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Images/AlertClient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/Images/AlertClient.png -------------------------------------------------------------------------------- /Images/DeviceSimulator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/Images/DeviceSimulator.png -------------------------------------------------------------------------------- /Images/VerticalArchitectureDesign.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paolosalvatori/servicefabriceventhubdemo/9ff4e611508eb1f0a1a43c7c34118cfbb22edb70/Images/VerticalArchitectureDesign.png -------------------------------------------------------------------------------- /IoTDemo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{A07B5EB6-E848-4116-A8D0-A826331D98C6}") = "IoTDemo", "IoTDemo\IoTDemo.sfproj", "{06786E84-03FC-4033-8C77-DB05D54BD2AF}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceManagementWebService", "DeviceManagementWebService\DeviceManagementWebService.csproj", "{B527FD03-1472-48BB-A2D2-50017CAABCE3}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventProcessorHostService", "EventProcessorHostService\EventProcessorHostService.csproj", "{CF36D4AB-5668-487C-9981-2E55B89C21FF}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceActorService", "DeviceActorService\DeviceActorService.csproj", "{A8FEEE4E-6854-4EE0-A9FB-899C81740191}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceActorService.Interfaces", "DeviceActorService.Interfaces\DeviceActorService.Interfaces.csproj", "{5053282C-E247-4FCB-8AEE-B45DF9C877C0}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AlertClient", "AlertClient\AlertClient.csproj", "{1746D00F-0F6C-477C-BEC8-0630D39E04A3}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PayloadEntities", "Entities\PayloadEntities.csproj", "{AA413FD4-FD2B-4B29-864C-E42915767176}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceSimulator", "DeviceSimulator\DeviceSimulator.csproj", "{25791060-8870-4D2D-A58A-D4CB91105E88}" 21 | EndProject 22 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documents", "Documents", "{1521FA9E-523D-459B-B2EA-539F50CAF94C}" 23 | ProjectSection(SolutionItems) = preProject 24 | README.md = README.md 25 | EndProjectSection 26 | EndProject 27 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Images", "Images", "{6306DD4B-6706-495E-9C87-42C6F5FC246B}" 28 | ProjectSection(SolutionItems) = preProject 29 | Images\AlertClient.png = Images\AlertClient.png 30 | Images\DeviceSimulator.png = Images\DeviceSimulator.png 31 | Images\VerticalArchitectureDesign.png = Images\VerticalArchitectureDesign.png 32 | EndProjectSection 33 | EndProject 34 | Global 35 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 36 | Debug|Any CPU = Debug|Any CPU 37 | Debug|x64 = Debug|x64 38 | Release|Any CPU = Release|Any CPU 39 | Release|x64 = Release|x64 40 | EndGlobalSection 41 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 42 | {06786E84-03FC-4033-8C77-DB05D54BD2AF}.Debug|Any CPU.ActiveCfg = Debug|x64 43 | {06786E84-03FC-4033-8C77-DB05D54BD2AF}.Debug|x64.ActiveCfg = Debug|x64 44 | {06786E84-03FC-4033-8C77-DB05D54BD2AF}.Debug|x64.Build.0 = Debug|x64 45 | {06786E84-03FC-4033-8C77-DB05D54BD2AF}.Debug|x64.Deploy.0 = Debug|x64 46 | {06786E84-03FC-4033-8C77-DB05D54BD2AF}.Release|Any CPU.ActiveCfg = Release|x64 47 | {06786E84-03FC-4033-8C77-DB05D54BD2AF}.Release|x64.ActiveCfg = Release|x64 48 | {06786E84-03FC-4033-8C77-DB05D54BD2AF}.Release|x64.Build.0 = Release|x64 49 | {06786E84-03FC-4033-8C77-DB05D54BD2AF}.Release|x64.Deploy.0 = Release|x64 50 | {B527FD03-1472-48BB-A2D2-50017CAABCE3}.Debug|Any CPU.ActiveCfg = Debug|x64 51 | {B527FD03-1472-48BB-A2D2-50017CAABCE3}.Debug|x64.ActiveCfg = Debug|x64 52 | {B527FD03-1472-48BB-A2D2-50017CAABCE3}.Debug|x64.Build.0 = Debug|x64 53 | {B527FD03-1472-48BB-A2D2-50017CAABCE3}.Release|Any CPU.ActiveCfg = Release|x64 54 | {B527FD03-1472-48BB-A2D2-50017CAABCE3}.Release|x64.ActiveCfg = Release|x64 55 | {B527FD03-1472-48BB-A2D2-50017CAABCE3}.Release|x64.Build.0 = Release|x64 56 | {CF36D4AB-5668-487C-9981-2E55B89C21FF}.Debug|Any CPU.ActiveCfg = Debug|x64 57 | {CF36D4AB-5668-487C-9981-2E55B89C21FF}.Debug|x64.ActiveCfg = Debug|x64 58 | {CF36D4AB-5668-487C-9981-2E55B89C21FF}.Debug|x64.Build.0 = Debug|x64 59 | {CF36D4AB-5668-487C-9981-2E55B89C21FF}.Release|Any CPU.ActiveCfg = Release|x64 60 | {CF36D4AB-5668-487C-9981-2E55B89C21FF}.Release|x64.ActiveCfg = Release|x64 61 | {CF36D4AB-5668-487C-9981-2E55B89C21FF}.Release|x64.Build.0 = Release|x64 62 | {A8FEEE4E-6854-4EE0-A9FB-899C81740191}.Debug|Any CPU.ActiveCfg = Debug|x64 63 | {A8FEEE4E-6854-4EE0-A9FB-899C81740191}.Debug|x64.ActiveCfg = Debug|x64 64 | {A8FEEE4E-6854-4EE0-A9FB-899C81740191}.Debug|x64.Build.0 = Debug|x64 65 | {A8FEEE4E-6854-4EE0-A9FB-899C81740191}.Release|Any CPU.ActiveCfg = Release|x64 66 | {A8FEEE4E-6854-4EE0-A9FB-899C81740191}.Release|x64.ActiveCfg = Release|x64 67 | {A8FEEE4E-6854-4EE0-A9FB-899C81740191}.Release|x64.Build.0 = Release|x64 68 | {5053282C-E247-4FCB-8AEE-B45DF9C877C0}.Debug|Any CPU.ActiveCfg = Debug|x64 69 | {5053282C-E247-4FCB-8AEE-B45DF9C877C0}.Debug|x64.ActiveCfg = Debug|x64 70 | {5053282C-E247-4FCB-8AEE-B45DF9C877C0}.Debug|x64.Build.0 = Debug|x64 71 | {5053282C-E247-4FCB-8AEE-B45DF9C877C0}.Release|Any CPU.ActiveCfg = Release|x64 72 | {5053282C-E247-4FCB-8AEE-B45DF9C877C0}.Release|x64.ActiveCfg = Release|x64 73 | {5053282C-E247-4FCB-8AEE-B45DF9C877C0}.Release|x64.Build.0 = Release|x64 74 | {1746D00F-0F6C-477C-BEC8-0630D39E04A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 75 | {1746D00F-0F6C-477C-BEC8-0630D39E04A3}.Debug|Any CPU.Build.0 = Debug|Any CPU 76 | {1746D00F-0F6C-477C-BEC8-0630D39E04A3}.Debug|x64.ActiveCfg = Debug|Any CPU 77 | {1746D00F-0F6C-477C-BEC8-0630D39E04A3}.Debug|x64.Build.0 = Debug|Any CPU 78 | {1746D00F-0F6C-477C-BEC8-0630D39E04A3}.Release|Any CPU.ActiveCfg = Release|Any CPU 79 | {1746D00F-0F6C-477C-BEC8-0630D39E04A3}.Release|Any CPU.Build.0 = Release|Any CPU 80 | {1746D00F-0F6C-477C-BEC8-0630D39E04A3}.Release|x64.ActiveCfg = Release|Any CPU 81 | {1746D00F-0F6C-477C-BEC8-0630D39E04A3}.Release|x64.Build.0 = Release|Any CPU 82 | {AA413FD4-FD2B-4B29-864C-E42915767176}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 83 | {AA413FD4-FD2B-4B29-864C-E42915767176}.Debug|Any CPU.Build.0 = Debug|Any CPU 84 | {AA413FD4-FD2B-4B29-864C-E42915767176}.Debug|x64.ActiveCfg = Debug|Any CPU 85 | {AA413FD4-FD2B-4B29-864C-E42915767176}.Debug|x64.Build.0 = Debug|Any CPU 86 | {AA413FD4-FD2B-4B29-864C-E42915767176}.Release|Any CPU.ActiveCfg = Release|Any CPU 87 | {AA413FD4-FD2B-4B29-864C-E42915767176}.Release|Any CPU.Build.0 = Release|Any CPU 88 | {AA413FD4-FD2B-4B29-864C-E42915767176}.Release|x64.ActiveCfg = Release|Any CPU 89 | {AA413FD4-FD2B-4B29-864C-E42915767176}.Release|x64.Build.0 = Release|Any CPU 90 | {25791060-8870-4D2D-A58A-D4CB91105E88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 91 | {25791060-8870-4D2D-A58A-D4CB91105E88}.Debug|Any CPU.Build.0 = Debug|Any CPU 92 | {25791060-8870-4D2D-A58A-D4CB91105E88}.Debug|x64.ActiveCfg = Debug|Any CPU 93 | {25791060-8870-4D2D-A58A-D4CB91105E88}.Debug|x64.Build.0 = Debug|Any CPU 94 | {25791060-8870-4D2D-A58A-D4CB91105E88}.Release|Any CPU.ActiveCfg = Release|Any CPU 95 | {25791060-8870-4D2D-A58A-D4CB91105E88}.Release|Any CPU.Build.0 = Release|Any CPU 96 | {25791060-8870-4D2D-A58A-D4CB91105E88}.Release|x64.ActiveCfg = Release|Any CPU 97 | {25791060-8870-4D2D-A58A-D4CB91105E88}.Release|x64.Build.0 = Release|Any CPU 98 | EndGlobalSection 99 | GlobalSection(SolutionProperties) = preSolution 100 | HideSolutionNode = FALSE 101 | EndGlobalSection 102 | EndGlobal 103 | -------------------------------------------------------------------------------- /IoTDemo/ApplicationPackageRoot/ApplicationManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 |
29 |
30 |
31 |
32 |
33 | 34 | 35 | 36 | 37 | 38 |
39 | 40 | 41 | 42 | 43 | 44 |
45 |
46 |
47 |
48 |
49 | 50 | 51 | 52 | 53 | 54 |
55 | 56 |
57 |
58 |
59 |
60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
-------------------------------------------------------------------------------- /IoTDemo/ApplicationParameters/Cloud.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /IoTDemo/ApplicationParameters/Local.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /IoTDemo/IoTDemo.sfproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 06786e84-03fc-4033-8c77-db05d54bd2af 6 | 1.0 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /IoTDemo/PublishProfiles/Cloud.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /IoTDemo/PublishProfiles/Local.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate --------------------------------------------------------------------------------