├── .gitignore ├── CONTRIBUTING.md ├── HealthMetrics.BandActor.Interfaces ├── BandDataViewModel.cs ├── BandInfo.cs ├── HealthMetrics.BandActor.Interfaces.csproj ├── HeartRateRecord.cs ├── IBandActor.cs ├── Properties │ └── AssemblyInfo.cs ├── app.config └── packages.config ├── HealthMetrics.BandActor ├── ActorEventSource.cs ├── App.config ├── BandActor.cs ├── HealthMetrics.BandActor.csproj ├── PackageRoot │ ├── Config │ │ └── Settings.xml │ └── ServiceManifest.xml ├── Properties │ └── AssemblyInfo.cs ├── ServiceHost.cs └── packages.config ├── HealthMetrics.BandCreationService ├── App.config ├── BandActorGenerator.cs ├── HealthMetrics.BandCreationService.csproj ├── PackageRoot │ ├── Config │ │ └── Settings.xml │ ├── Data │ │ ├── HealthMetrics.Common.csv │ │ └── Names.csv │ └── ServiceManifest.xml ├── Properties │ └── AssemblyInfo.cs ├── Service.cs ├── ServiceEventSource.cs ├── ServiceHost.cs └── packages.config ├── HealthMetrics.Common ├── CalculationMode.cs ├── CountyRecord.cs ├── CountyStatsViewModel.cs ├── CryptoRandom.cs ├── HashUtil.cs ├── HealthIndex.cs ├── HealthIndexCalculator.cs ├── HealthMetrics.Common.csproj ├── HttpClientExtensions.cs ├── HttpCommunicationClient.cs ├── HttpCommunicationClientFactory.cs ├── HttpCommunicationListener.cs ├── IOwinAppBuilder.cs ├── NationalStatsViewModel.cs ├── Properties │ └── AssemblyInfo.cs ├── ServicePrimer.cs ├── ServiceUriBuilder.cs ├── app.config └── packages.config ├── HealthMetrics.CountyService ├── App.config ├── App_Start │ ├── FormatterConfig.cs │ └── UnityConfig.cs ├── Controllers │ ├── CountyDoctorsController.cs │ └── CountyHealthController.cs ├── HealthMetrics.CountyService.csproj ├── Models │ ├── CountyDoctorStats.cs │ └── HistogramData.cs ├── PackageRoot │ ├── Config │ │ └── Settings.xml │ └── ServiceManifest.xml ├── Properties │ └── AssemblyInfo.cs ├── Service.cs ├── ServiceEventSource.cs ├── ServiceHost.cs ├── Startup.cs └── packages.config ├── HealthMetrics.DoctorActor.Interfaces ├── DoctorStatsViewModel.cs ├── HealthMetrics.DoctorActor.Interfaces.csproj ├── IDoctorActor.cs ├── PatientDataViewModel.cs ├── Properties │ └── AssemblyInfo.cs ├── app.config └── packages.config ├── HealthMetrics.DoctorActor ├── ActorEventSource.cs ├── App.config ├── DoctorActor.cs ├── DoctorPatientState.cs ├── HealthMetrics.DoctorActor.csproj ├── PackageRoot │ ├── Config │ │ └── Settings.xml │ └── ServiceManifest.xml ├── Properties │ └── AssemblyInfo.cs ├── ServiceHost.cs └── packages.config ├── HealthMetrics.NationalService ├── App.config ├── App_Start │ ├── FormatterConfig.cs │ └── UnityConfig.cs ├── Controllers │ ├── NationalHealthController.cs │ └── NationalStatsController.cs ├── HealthMetrics.NationalService.csproj ├── Models │ ├── CountyHealth.cs │ ├── NationalCountyStats.cs │ └── VoteTotals.cs ├── PackageRoot │ ├── Config │ │ └── Settings.xml │ └── ServiceManifest.xml ├── Properties │ └── AssemblyInfo.cs ├── Service.cs ├── ServiceEventSource.cs ├── ServiceHost.cs ├── Startup.cs └── packages.config ├── HealthMetrics.WebService ├── App.config ├── App_Start │ ├── FormatterConfig.cs │ └── UnityConfig.cs ├── Controllers │ └── DefaultApiController.cs ├── HealthMetrics.WebService.csproj ├── PackageRoot │ ├── Config │ │ └── Settings.xml │ └── ServiceManifest.xml ├── Properties │ └── AssemblyInfo.cs ├── Scripts │ ├── angular-mocks.js │ ├── angular.js │ ├── angular.min.js │ ├── angular.min.js.map │ ├── d3 │ │ ├── API.md │ │ ├── CHANGES.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── d3.js │ │ └── d3.min.js │ ├── jqPlot │ │ ├── MIT-LICENSE.txt │ │ ├── README.txt │ │ ├── changes.txt │ │ ├── copyright.txt │ │ ├── excanvas.js │ │ ├── excanvas.min.js │ │ ├── gpl-2.0.txt │ │ ├── jqPlotCssStyling.txt │ │ ├── jqPlotOptions.txt │ │ ├── jquery.jqplot.css │ │ ├── jquery.jqplot.js │ │ ├── jquery.jqplot.min.css │ │ ├── jquery.jqplot.min.js │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ ├── optionsTutorial.txt │ │ ├── plugins │ │ │ ├── jqplot.BezierCurveRenderer.js │ │ │ ├── jqplot.BezierCurveRenderer.min.js │ │ │ ├── jqplot.barRenderer.js │ │ │ ├── jqplot.barRenderer.min.js │ │ │ ├── jqplot.blockRenderer.js │ │ │ ├── jqplot.blockRenderer.min.js │ │ │ ├── jqplot.bubbleRenderer.js │ │ │ ├── jqplot.bubbleRenderer.min.js │ │ │ ├── jqplot.canvasAxisLabelRenderer.js │ │ │ ├── jqplot.canvasAxisLabelRenderer.min.js │ │ │ ├── jqplot.canvasAxisTickRenderer.js │ │ │ ├── jqplot.canvasAxisTickRenderer.min.js │ │ │ ├── jqplot.canvasOverlay.js │ │ │ ├── jqplot.canvasOverlay.min.js │ │ │ ├── jqplot.canvasTextRenderer.js │ │ │ ├── jqplot.canvasTextRenderer.min.js │ │ │ ├── jqplot.categoryAxisRenderer.js │ │ │ ├── jqplot.categoryAxisRenderer.min.js │ │ │ ├── jqplot.ciParser.js │ │ │ ├── jqplot.ciParser.min.js │ │ │ ├── jqplot.cursor.js │ │ │ ├── jqplot.cursor.min.js │ │ │ ├── jqplot.dateAxisRenderer.js │ │ │ ├── jqplot.dateAxisRenderer.min.js │ │ │ ├── jqplot.donutRenderer.js │ │ │ ├── jqplot.donutRenderer.min.js │ │ │ ├── jqplot.dragable.js │ │ │ ├── jqplot.dragable.min.js │ │ │ ├── jqplot.enhancedLegendRenderer.js │ │ │ ├── jqplot.enhancedLegendRenderer.min.js │ │ │ ├── jqplot.funnelRenderer.js │ │ │ ├── jqplot.funnelRenderer.min.js │ │ │ ├── jqplot.highlighter.js │ │ │ ├── jqplot.highlighter.min.js │ │ │ ├── jqplot.json2.js │ │ │ ├── jqplot.json2.min.js │ │ │ ├── jqplot.logAxisRenderer.js │ │ │ ├── jqplot.logAxisRenderer.min.js │ │ │ ├── jqplot.mekkoAxisRenderer.js │ │ │ ├── jqplot.mekkoAxisRenderer.min.js │ │ │ ├── jqplot.mekkoRenderer.js │ │ │ ├── jqplot.mekkoRenderer.min.js │ │ │ ├── jqplot.meterGaugeRenderer.js │ │ │ ├── jqplot.meterGaugeRenderer.min.js │ │ │ ├── jqplot.mobile.js │ │ │ ├── jqplot.mobile.min.js │ │ │ ├── jqplot.ohlcRenderer.js │ │ │ ├── jqplot.ohlcRenderer.min.js │ │ │ ├── jqplot.pieRenderer.js │ │ │ ├── jqplot.pieRenderer.min.js │ │ │ ├── jqplot.pointLabels.js │ │ │ ├── jqplot.pointLabels.min.js │ │ │ ├── jqplot.pyramidAxisRenderer.js │ │ │ ├── jqplot.pyramidAxisRenderer.min.js │ │ │ ├── jqplot.pyramidGridRenderer.js │ │ │ ├── jqplot.pyramidGridRenderer.min.js │ │ │ ├── jqplot.pyramidRenderer.js │ │ │ ├── jqplot.pyramidRenderer.min.js │ │ │ ├── jqplot.trendline.js │ │ │ └── jqplot.trendline.min.js │ │ └── usage.txt │ └── jquery-3.1.1.min.js ├── Service.cs ├── ServiceEventSource.cs ├── ServiceHost.cs ├── Startup.cs ├── packages.config └── wwwroot │ ├── Content │ ├── jquery.jqplot.css │ ├── main.css │ └── us-10m.json │ ├── Scripts │ ├── angular.min.js │ ├── api.js │ ├── d3 │ │ ├── d3-composite-projections.js │ │ └── d3.min.js │ ├── healthmetrics.js │ ├── jquery-3.1.1.min.js │ └── topojson.min.js │ └── index.html ├── HealthMetrics.sln ├── HealthMetricsApplication ├── ApplicationPackageRoot │ └── ApplicationManifest.xml ├── ApplicationParameters │ ├── Cloud.xml │ ├── Local.1Node.xml │ ├── Local.5Node.xml │ └── Local.xml ├── HealthMetrics.exe.config ├── HealthMetrics.sfproj ├── PublishProfiles │ ├── Cloud.xml │ ├── Local.1Node.xml │ ├── Local.5Node.xml │ └── Local.xml ├── Scripts │ ├── ApplicationPackageUpgrade.ps1 │ ├── Deploy-FabricApplication.ps1 │ ├── HealthMetricsCleanup.ps1 │ ├── HealthMetricsConfigParamUpgrade.ps1 │ ├── HealthMetricsDeployment.ps1 │ └── HealthMetricsV2ConfigOnlyPackage │ │ └── ApplicationManifest.xml ├── app.config └── packages.config ├── LICENSE └── README.md /.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 | pkg/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # Visual Studio 2015 cache/options directory 25 | .vs/ 26 | 27 | # MSTest test Results 28 | [Tt]est[Rr]esult*/ 29 | [Bb]uild[Ll]og.* 30 | 31 | # NUNIT 32 | *.VisualState.xml 33 | TestResult.xml 34 | 35 | # Build Results of an ATL Project 36 | [Dd]ebugPS/ 37 | [Rr]eleasePS/ 38 | dlldata.c 39 | 40 | # DNX 41 | project.lock.json 42 | artifacts/ 43 | 44 | *_i.c 45 | *_p.c 46 | *_i.h 47 | *.ilk 48 | *.meta 49 | *.obj 50 | *.pch 51 | *.pdb 52 | *.pgc 53 | *.pgd 54 | *.rsp 55 | *.sbr 56 | *.tlb 57 | *.tli 58 | *.tlh 59 | *.tmp 60 | *.tmp_proj 61 | *.log 62 | *.vspscc 63 | *.vssscc 64 | .builds 65 | *.pidb 66 | *.svclog 67 | *.scc 68 | 69 | # Chutzpah Test files 70 | _Chutzpah* 71 | 72 | # Visual C++ cache files 73 | ipch/ 74 | *.aps 75 | *.ncb 76 | *.opensdf 77 | *.sdf 78 | *.cachefile 79 | 80 | # Visual Studio profiler 81 | *.psess 82 | *.vsp 83 | *.vspx 84 | 85 | # TFS 2012 Local Workspace 86 | $tf/ 87 | 88 | # Guidance Automation Toolkit 89 | *.gpState 90 | 91 | # ReSharper is a .NET coding add-in 92 | _ReSharper*/ 93 | *.[Rr]e[Ss]harper 94 | *.DotSettings.user 95 | 96 | # JustCode is a .NET coding add-in 97 | .JustCode 98 | 99 | # TeamCity is a build add-in 100 | _TeamCity* 101 | 102 | # DotCover is a Code Coverage Tool 103 | *.dotCover 104 | 105 | # NCrunch 106 | _NCrunch_* 107 | .*crunch*.local.xml 108 | 109 | # MightyMoose 110 | *.mm.* 111 | AutoTest.Net/ 112 | 113 | # Web workbench (sass) 114 | .sass-cache/ 115 | 116 | # Installshield output folder 117 | [Ee]xpress/ 118 | 119 | # DocProject is a documentation generator add-in 120 | DocProject/buildhelp/ 121 | DocProject/Help/*.HxT 122 | DocProject/Help/*.HxC 123 | DocProject/Help/*.hhc 124 | DocProject/Help/*.hhk 125 | DocProject/Help/*.hhp 126 | DocProject/Help/Html2 127 | DocProject/Help/html 128 | 129 | # Click-Once directory 130 | publish/ 131 | 132 | # Publish Web Output 133 | *.[Pp]ublish.xml 134 | *.azurePubxml 135 | ## TODO: Comment the next line if you want to checkin your 136 | ## web deploy settings but do note that will include unencrypted 137 | ## passwords 138 | #*.pubxml 139 | 140 | *.publishproj 141 | 142 | # NuGet Packages 143 | *.nupkg 144 | # The packages folder can be ignored because of Package Restore 145 | **/packages/* 146 | # except build/, which is used as an MSBuild target. 147 | !**/packages/build/ 148 | # Uncomment if necessary however generally it will be regenerated when needed 149 | #!**/packages/repositories.config 150 | 151 | # Windows Azure Build Output 152 | csx/ 153 | *.build.csdef 154 | 155 | # Windows Store app package directory 156 | AppPackages/ 157 | 158 | # Visual Studio cache files 159 | # files ending in .cache can be ignored 160 | *.[Cc]ache 161 | # but keep track of directories ending in .cache 162 | !*.[Cc]ache/ 163 | 164 | # Others 165 | ClientBin/ 166 | [Ss]tyle[Cc]op.* 167 | ~$* 168 | *~ 169 | *.dbmdl 170 | *.dbproj.schemaview 171 | *.pfx 172 | *.publishsettings 173 | node_modules/ 174 | orleans.codegen.cs 175 | 176 | # RIA/Silverlight projects 177 | Generated_Code/ 178 | 179 | # Backup & report files from converting an old project file 180 | # to a newer Visual Studio version. Backup files are not needed, 181 | # because we have git ;-) 182 | _UpgradeReport_Files/ 183 | Backup*/ 184 | UpgradeLog*.XML 185 | UpgradeLog*.htm 186 | 187 | # SQL Server files 188 | *.mdf 189 | *.ldf 190 | 191 | # Business Intelligence projects 192 | *.rdl.data 193 | *.bim.layout 194 | *.bim_*.settings 195 | 196 | # Microsoft Fakes 197 | FakesAssemblies/ 198 | 199 | # Node.js Tools for Visual Studio 200 | .ntvs_analysis.dat 201 | 202 | # Visual Studio 6 build log 203 | *.plg 204 | 205 | # Visual Studio 6 workspace options file 206 | *.opt 207 | 208 | # LightSwitch generated files 209 | GeneratedArtifacts/ 210 | _Pvt_Extensions/ 211 | ModelManifest.xml 212 | /ServiceFabricServicesBackup 213 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Azure samples 2 | 3 | Thank you for your interest in contributing to Azure samples! 4 | 5 | ## Ways to contribute 6 | 7 | You can contribute to [Azure samples](https://azure.microsoft.com/documentation/samples/) in a few different ways: 8 | 9 | - Submit feedback on [this sample page](https://azure.microsoft.com/documentation/samples/service-fabric-dotnet-data-aggregation/) whether it was helpful or not. 10 | - Submit issues through [issue tracker](https://github.com/Azure-Samples/service-fabric-dotnet-data-aggregation/issues) on GitHub. We are actively monitoring the issues and improving our samples. 11 | - If you wish to make code changes to samples, or contribute something new, please follow the [GitHub Forks / Pull requests model](https://help.github.com/articles/fork-a-repo/): Fork the sample repo, make the change and propose it back by submitting a pull request. -------------------------------------------------------------------------------- /HealthMetrics.BandActor.Interfaces/BandDataViewModel.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.BandActor.Interfaces 7 | { 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Runtime.Serialization; 11 | using HealthMetrics.Common; 12 | 13 | [DataContract] 14 | public struct BandDataViewModel 15 | { 16 | public BandDataViewModel( 17 | Guid doctorId, 18 | Guid bandId, 19 | string patientName, 20 | CountyRecord countyInfo, 21 | HealthIndex healthIndexValue, 22 | IEnumerable heartRateHistory) 23 | { 24 | this.DoctorId = doctorId; 25 | this.PersonId = bandId; 26 | this.PersonName = patientName; 27 | this.CountyInfo = countyInfo; 28 | this.HealthIndexValue = healthIndexValue; 29 | this.HeartRateHistory = heartRateHistory; 30 | } 31 | 32 | [DataMember] 33 | public Guid DoctorId { get; private set; } 34 | 35 | [DataMember] 36 | public Guid PersonId { get; private set; } 37 | 38 | [DataMember] 39 | public string PersonName { get; private set; } 40 | 41 | [DataMember] 42 | public CountyRecord CountyInfo { get; private set; } 43 | 44 | [DataMember] 45 | public HealthIndex HealthIndexValue { get; private set; } 46 | 47 | [DataMember] 48 | public IEnumerable HeartRateHistory { get; private set; } 49 | 50 | public override string ToString() 51 | { 52 | return string.Format("{0}|{1}|{2}|{3}|{4}", this.DoctorId, this.PersonId, this.PersonName, this.CountyInfo, this.HealthIndexValue); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /HealthMetrics.BandActor.Interfaces/BandInfo.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.BandActor.Interfaces 7 | { 8 | using System; 9 | using System.Runtime.Serialization; 10 | using HealthMetrics.Common; 11 | 12 | [DataContract] 13 | public struct BandInfo 14 | { 15 | [DataMember] 16 | public Guid DoctorId { get; set; } 17 | 18 | [DataMember] 19 | public CountyRecord CountyInfo { get; set; } 20 | 21 | [DataMember] 22 | public HealthIndex HealthIndex { get; set; } 23 | 24 | [DataMember] 25 | public string PersonName { get; set; } 26 | 27 | public static bool operator ==(BandInfo a, BandInfo b) 28 | { 29 | if (a.DoctorId == b.DoctorId 30 | && a.CountyInfo == b.CountyInfo 31 | && a.HealthIndex == b.HealthIndex 32 | && a.PersonName == b.PersonName) 33 | { 34 | return true; 35 | } 36 | else 37 | { 38 | return false; 39 | } 40 | } 41 | 42 | public static bool operator !=(BandInfo a, BandInfo b) 43 | { 44 | return !(a == b); 45 | } 46 | 47 | public override bool Equals(object obj) 48 | { 49 | return (this == (BandInfo) obj); 50 | } 51 | 52 | public override int GetHashCode() 53 | { 54 | return HashUtil.getIntHashCode(this.ToString()); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /HealthMetrics.BandActor.Interfaces/HeartRateRecord.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.BandActor.Interfaces 7 | { 8 | using System; 9 | using System.Runtime.Serialization; 10 | 11 | [DataContract] 12 | public struct HeartRateRecord 13 | { 14 | [DataMember] 15 | public float HeartRate { get; private set; } 16 | 17 | [DataMember] 18 | public DateTimeOffset Timestamp { get; private set; } 19 | 20 | public HeartRateRecord(float heartRate) 21 | { 22 | this.HeartRate = heartRate; 23 | this.Timestamp = DateTimeOffset.UtcNow; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /HealthMetrics.BandActor.Interfaces/IBandActor.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.BandActor.Interfaces 7 | { 8 | using System.Threading.Tasks; 9 | using Microsoft.ServiceFabric.Actors; 10 | 11 | public interface IBandActor : IActor 12 | { 13 | Task NewAsync(BandInfo info); 14 | 15 | Task GetBandDataAsync(); 16 | } 17 | } -------------------------------------------------------------------------------- /HealthMetrics.BandActor.Interfaces/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | 13 | [assembly: AssemblyTitle("HealthMetrics.BandActor.Interfaces")] 14 | [assembly: AssemblyDescription("")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("")] 17 | [assembly: AssemblyProduct("HealthMetrics.BandActor.Interfaces")] 18 | [assembly: AssemblyCopyright("Copyright © 2015")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | 28 | // The following GUID is for the ID of the typelib if this project is exposed to COM 29 | 30 | [assembly: Guid("60ffaf07-b6d6-4f68-b7a4-156d72ccd05a")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | 43 | [assembly: AssemblyVersion("1.0.0.0")] 44 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /HealthMetrics.BandActor.Interfaces/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /HealthMetrics.BandActor.Interfaces/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /HealthMetrics.BandActor/ActorEventSource.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.BandActor 7 | { 8 | using System; 9 | using System.Diagnostics.Tracing; 10 | using System.Fabric; 11 | using Microsoft.ServiceFabric.Actors.Runtime; 12 | 13 | [EventSource(Name = "MyCompany-HealthMetrics-HealthMetrics.BandActor")] 14 | internal sealed class ActorEventSource : EventSource 15 | { 16 | private const int MessageEventId = 1; 17 | 18 | private const int ActorMessageEventId = 2; 19 | 20 | private const int ActorHostInitializationFailedEventId = 3; 21 | public static readonly ActorEventSource Current = new ActorEventSource(); 22 | 23 | [NonEvent] 24 | public void Message(string message, params object[] args) 25 | { 26 | if (this.IsEnabled()) 27 | { 28 | string finalMessage = string.Format(message, args); 29 | this.Message(finalMessage); 30 | } 31 | } 32 | 33 | [Event(MessageEventId, Level = EventLevel.Informational, Message = "{0}")] 34 | public void Message(string message) 35 | { 36 | if (this.IsEnabled()) 37 | { 38 | this.WriteEvent(MessageEventId, message); 39 | } 40 | } 41 | 42 | [NonEvent] 43 | public void ActorMessage(Actor actor, string message, params object[] args) 44 | { 45 | if (this.IsEnabled()) 46 | { 47 | string finalMessage = string.Format(message, args); 48 | this.ActorMessage( 49 | actor.GetType().ToString(), 50 | actor.Id.ToString(), 51 | actor.ActorService.Context.CodePackageActivationContext.ApplicationTypeName, 52 | actor.ActorService.Context.CodePackageActivationContext.ApplicationName, 53 | actor.ActorService.Context.ServiceTypeName, 54 | actor.ActorService.Context.ServiceName.ToString(), 55 | actor.ActorService.Context.PartitionId, 56 | actor.ActorService.Context.ReplicaId, 57 | FabricRuntime.GetNodeContext().NodeName, 58 | finalMessage); 59 | } 60 | } 61 | 62 | [NonEvent] 63 | public void ActorHostInitializationFailed(Exception e) 64 | { 65 | if (this.IsEnabled()) 66 | { 67 | this.ActorHostInitializationFailed(e.ToString()); 68 | } 69 | } 70 | 71 | [Event(ActorMessageEventId, Level = EventLevel.Informational, Message = "{9}")] 72 | private 73 | void ActorMessage( 74 | string actorType, 75 | string actorId, 76 | string applicationTypeName, 77 | string applicationName, 78 | string serviceTypeName, 79 | string serviceName, 80 | Guid partitionId, 81 | long replicaOrInstanceId, 82 | string nodeName, 83 | string message) 84 | { 85 | this.WriteEvent( 86 | ActorMessageEventId, 87 | actorType, 88 | actorId, 89 | applicationTypeName, 90 | applicationName, 91 | serviceTypeName, 92 | serviceName, 93 | partitionId, 94 | replicaOrInstanceId, 95 | nodeName, 96 | message); 97 | } 98 | 99 | [Event(ActorHostInitializationFailedEventId, Level = EventLevel.Error, Message = "Actor host initialization failed")] 100 | private void ActorHostInitializationFailed(string exception) 101 | { 102 | this.WriteEvent(ActorHostInitializationFailedEventId, exception); 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /HealthMetrics.BandActor/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /HealthMetrics.BandActor/PackageRoot/Config/Settings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 |
4 | 5 | 6 |
7 |
8 | 9 |
10 |
11 | 12 |
13 |
14 | 15 |
16 |
-------------------------------------------------------------------------------- /HealthMetrics.BandActor/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 | HealthMetrics.BandActor.exe 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /HealthMetrics.BandActor/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | 13 | [assembly: AssemblyTitle("HealthMetrics.BandActor")] 14 | [assembly: AssemblyDescription("")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("")] 17 | [assembly: AssemblyProduct("HealthMetrics.BandActor")] 18 | [assembly: AssemblyCopyright("Copyright © 2015")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | 28 | // The following GUID is for the ID of the typelib if this project is exposed to COM 29 | 30 | [assembly: Guid("b8b9a1e2-c158-4b6c-8fd2-86eaabe177bc")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | 43 | [assembly: AssemblyVersion("1.0.0.0")] 44 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /HealthMetrics.BandActor/ServiceHost.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.BandActor 7 | { 8 | using System; 9 | using System.Threading; 10 | using Microsoft.ServiceFabric.Actors.Runtime; 11 | 12 | public class ServiceHost 13 | { 14 | public static void Main(string[] args) 15 | { 16 | try 17 | { 18 | ActorRuntime.RegisterActorAsync(); 19 | 20 | Thread.Sleep(Timeout.Infinite); 21 | } 22 | catch (Exception e) 23 | { 24 | ActorEventSource.Current.ActorHostInitializationFailed(e); 25 | throw; 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /HealthMetrics.BandActor/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /HealthMetrics.BandCreationService/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 | -------------------------------------------------------------------------------- /HealthMetrics.BandCreationService/PackageRoot/Config/Settings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /HealthMetrics.BandCreationService/PackageRoot/ServiceManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | HealthMetrics.BandCreationService.exe 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /HealthMetrics.BandCreationService/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | 13 | [assembly: AssemblyTitle("HealthMetrics.BandCreationService")] 14 | [assembly: AssemblyDescription("")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("")] 17 | [assembly: AssemblyProduct("HealthMetrics.BandCreationService")] 18 | [assembly: AssemblyCopyright("Copyright © 2015")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | 28 | // The following GUID is for the ID of the typelib if this project is exposed to COM 29 | 30 | [assembly: Guid("ece13121-9b78-4f90-8529-ce7dc9279c42")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | 43 | [assembly: AssemblyVersion("1.0.0.0")] 44 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /HealthMetrics.BandCreationService/ServiceHost.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.BandCreationService 7 | { 8 | using System; 9 | using System.Diagnostics; 10 | using System.Net; 11 | using System.Threading; 12 | using Microsoft.ServiceFabric.Services.Runtime; 13 | 14 | public class ServiceHost 15 | { 16 | public static void Main(string[] args) 17 | { 18 | try 19 | { 20 | ServicePointManager.DefaultConnectionLimit = 1024; 21 | ServicePointManager.SetTcpKeepAlive(true, 5000, 1000); 22 | ServicePointManager.UseNagleAlgorithm = false; 23 | 24 | ServiceRuntime.RegisterServiceAsync(Service.ServiceTypeName, context => new Service(context)).GetAwaiter().GetResult(); 25 | 26 | ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, Service.ServiceTypeName); 27 | 28 | Thread.Sleep(Timeout.Infinite); 29 | } 30 | catch (Exception e) 31 | { 32 | ServiceEventSource.Current.ServiceHostInitializationFailed(e); 33 | throw; 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /HealthMetrics.BandCreationService/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /HealthMetrics.Common/CalculationMode.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | public enum CalculationMode 9 | { 10 | Simple, 11 | 12 | Detailed 13 | } 14 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/CountyRecord.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | using System.Runtime.Serialization; 9 | 10 | [DataContract] 11 | public struct CountyRecord 12 | { 13 | [DataMember] 14 | public string CountyName { get; set; } 15 | 16 | [DataMember] 17 | public int CountyId { get; set; } 18 | 19 | [DataMember] 20 | public double CountyHealth { get; set; } 21 | 22 | public CountyRecord(string name, int id, double countyHealth) 23 | { 24 | this.CountyName = name; 25 | this.CountyId = id; 26 | this.CountyHealth = countyHealth; 27 | } 28 | 29 | public long GetLongPartitionKey() 30 | { 31 | return HashUtil.getLongHashCode(this.ToString()); 32 | } 33 | 34 | public static bool operator ==(CountyRecord a, CountyRecord b) 35 | { 36 | if (a.CountyHealth == b.CountyHealth 37 | && a.CountyId == b.CountyId 38 | && a.CountyName == b.CountyName) 39 | { 40 | return true; 41 | } 42 | else 43 | { 44 | return false; 45 | } 46 | } 47 | 48 | public static bool operator !=(CountyRecord a, CountyRecord b) 49 | { 50 | return !(a == b); 51 | } 52 | 53 | public override string ToString() 54 | { 55 | return string.Format("[{0}|{1}]", this.CountyId, this.CountyHealth); 56 | } 57 | 58 | public override bool Equals(object obj) 59 | { 60 | return (this == (CountyRecord) obj); 61 | } 62 | 63 | public override int GetHashCode() 64 | { 65 | return HashUtil.getIntHashCode(this.ToString()); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/CountyStatsViewModel.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | using System.Runtime.Serialization; 9 | 10 | [DataContract] 11 | public struct CountyStatsViewModel 12 | { 13 | public CountyStatsViewModel(int doctorCount, int patientCount, long healthReportCount, HealthIndex averageHealthIndex) 14 | { 15 | this.AverageHealthIndex = averageHealthIndex; 16 | this.DoctorCount = doctorCount; 17 | this.PatientCount = patientCount; 18 | this.HealthReportCount = healthReportCount; 19 | } 20 | 21 | [DataMember] 22 | public int DoctorCount { get; private set; } 23 | 24 | [DataMember] 25 | public int PatientCount { get; private set; } 26 | 27 | [DataMember] 28 | public long HealthReportCount { get; private set; } 29 | 30 | [DataMember] 31 | public HealthIndex AverageHealthIndex { get; private set; } 32 | } 33 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/HashUtil.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | using System; 9 | using System.Security.Cryptography; 10 | using System.Text; 11 | 12 | public class HashUtil 13 | { 14 | public static long getLongHashCode(string stringInput) 15 | { 16 | byte[] byteContents = Encoding.Unicode.GetBytes(stringInput); 17 | MD5CryptoServiceProvider hash = new MD5CryptoServiceProvider(); 18 | byte[] hashText = hash.ComputeHash(byteContents); 19 | return BitConverter.ToInt64(hashText, 0) ^ BitConverter.ToInt64(hashText, 7); 20 | } 21 | 22 | public static int getIntHashCode(string stringInput) 23 | { 24 | return (int) getLongHashCode(stringInput); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/HealthIndex.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | using System; 9 | using System.Runtime.Serialization; 10 | 11 | [DataContract] 12 | public struct HealthIndex : IComparable, IComparable, IEquatable 13 | { 14 | [DataMember] private int value; 15 | [DataMember] private bool mode; 16 | 17 | public HealthIndex(int value, bool mode) 18 | { 19 | this.value = value; 20 | this.mode = mode; 21 | } 22 | 23 | public int CompareTo(HealthIndex other) 24 | { 25 | return this.value.CompareTo(other.value); 26 | } 27 | 28 | //public static explicit operator HealthIndex(int value, bool mode) 29 | //{ 30 | // return new HealthIndex(value, mode); 31 | //} 32 | 33 | public static bool operator ==(HealthIndex item1, HealthIndex item2) 34 | { 35 | return item1.Equals(item2); 36 | } 37 | 38 | public static bool operator !=(HealthIndex item1, HealthIndex item2) 39 | { 40 | return !item1.Equals(item2); 41 | } 42 | 43 | public static bool operator >(HealthIndex item1, HealthIndex item2) 44 | { 45 | return item1.value > item2.value; 46 | } 47 | 48 | public static bool operator >=(HealthIndex item1, HealthIndex item2) 49 | { 50 | return item1.value >= item2.value; 51 | } 52 | 53 | public static bool operator <(HealthIndex item1, HealthIndex item2) 54 | { 55 | return item1.value < item2.value; 56 | } 57 | 58 | public static bool operator <=(HealthIndex item1, HealthIndex item2) 59 | { 60 | return item1.value <= item2.value; 61 | } 62 | 63 | public int CompareTo(object obj) 64 | { 65 | return this.CompareTo((HealthIndex) obj); 66 | } 67 | 68 | public bool Equals(HealthIndex other) 69 | { 70 | return (this.value.Equals(other.value) && this.mode.Equals(other.mode)); 71 | } 72 | 73 | public override bool Equals(object obj) 74 | { 75 | if (obj is HealthIndex) 76 | { 77 | return this.Equals((HealthIndex) obj); 78 | } 79 | 80 | return false; 81 | } 82 | 83 | public override string ToString() 84 | { 85 | return this.value.ToString(); 86 | } 87 | 88 | public override int GetHashCode() 89 | { 90 | return this.value.GetHashCode(); 91 | } 92 | 93 | internal int GetValue() 94 | { 95 | return this.value; 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/HealthIndexCalculator.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Collections.ObjectModel; 11 | using System.Fabric; 12 | using System.Fabric.Description; 13 | using System.Linq; 14 | 15 | public class HealthIndexCalculator 16 | { 17 | private CalculationMode calculationMode; 18 | 19 | public HealthIndexCalculator(ServiceContext serviceParamaters) 20 | { 21 | if (serviceParamaters.CodePackageActivationContext.GetConfigurationPackageNames().Contains("Config")) 22 | { 23 | ConfigurationPackage configPackage = serviceParamaters.CodePackageActivationContext.GetConfigurationPackageObject("Config"); 24 | 25 | this.UpdateConfigSettings(configPackage.Settings); 26 | 27 | serviceParamaters.CodePackageActivationContext.ConfigurationPackageModifiedEvent 28 | += this.CodePackageActivationContext_ConfigurationPackageModifiedEvent; 29 | } 30 | else 31 | { 32 | this.calculationMode = CalculationMode.Simple; 33 | } 34 | } 35 | 36 | public HealthIndex ComputeIndex(int value) 37 | { 38 | return new HealthIndex(value, (this.calculationMode == CalculationMode.Simple) ? false : true); 39 | } 40 | 41 | public HealthIndex ComputeIndex(HealthIndex value) 42 | { 43 | return new HealthIndex(value.GetValue(), (this.calculationMode == CalculationMode.Simple) ? false : true); 44 | } 45 | 46 | public HealthIndex ComputeAverageIndex(IEnumerable indices) 47 | { 48 | return this.ComputeIndex((int) Math.Round(indices.Average(x => x.GetValue()), 0)); 49 | } 50 | 51 | private void UpdateConfigSettings(ConfigurationSettings configSettings) 52 | { 53 | try 54 | { 55 | KeyedCollection parameters = configSettings.Sections["HealthIndexCalculator.Settings"].Parameters; 56 | 57 | string scoreCalculationMode = parameters["ScoreCalculationMode"].Value; 58 | 59 | this.calculationMode = String.Equals("Mode1", scoreCalculationMode, StringComparison.OrdinalIgnoreCase) 60 | ? CalculationMode.Simple 61 | : CalculationMode.Detailed; 62 | } 63 | catch (Exception) 64 | { 65 | //do nothing 66 | } 67 | } 68 | 69 | private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(object sender, PackageModifiedEventArgs e) 70 | { 71 | this.UpdateConfigSettings(e.NewPackage.Settings); 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/HttpClientExtensions.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace System.Net.Http 7 | { 8 | using System.Fabric; 9 | using System.Threading; 10 | using System.Threading.Tasks; 11 | using HealthMetrics.Common; 12 | using Microsoft.ServiceFabric.Services.Client; 13 | using Microsoft.ServiceFabric.Services.Communication.Client; 14 | 15 | public static class HttpClientExtensions 16 | { 17 | private static FabricClient fabricClient = new FabricClient(); 18 | 19 | private static HttpCommunicationClientFactory clientFactory = new HttpCommunicationClientFactory( 20 | ServicePartitionResolver.GetDefault(), 21 | "endpointName", 22 | TimeSpan.FromSeconds(2), 23 | TimeSpan.FromSeconds(2)); 24 | 25 | 26 | public static Task SendToServiceAsync( 27 | this HttpClient instance, Uri serviceInstanceUri, long partitionKey, Func createRequest, 28 | CancellationToken cancellationToken = default(CancellationToken)) 29 | { 30 | ServicePartitionClient servicePartitionClient = new ServicePartitionClient( 31 | clientFactory, 32 | serviceInstanceUri, 33 | new ServicePartitionKey(partitionKey)); 34 | 35 | return MakeHttpRequest(instance, createRequest, cancellationToken, servicePartitionClient); 36 | } 37 | 38 | public static Task SendToServiceAsync( 39 | this HttpClient instance, Uri serviceInstanceUri, Func createRequest, 40 | CancellationToken cancellationToken = default(CancellationToken)) 41 | { 42 | ServicePartitionClient servicePartitionClient = new ServicePartitionClient( 43 | clientFactory, 44 | serviceInstanceUri); 45 | 46 | return MakeHttpRequest(instance, createRequest, cancellationToken, servicePartitionClient); 47 | } 48 | 49 | private static Task MakeHttpRequest( 50 | HttpClient instance, Func createRequest, CancellationToken cancellationToken, 51 | ServicePartitionClient servicePartitionClient) 52 | { 53 | return servicePartitionClient.InvokeWithRetryAsync( 54 | async 55 | client => 56 | { 57 | HttpRequestMessage request = createRequest(); 58 | 59 | Uri newUri = new Uri(client.BaseAddress, request.RequestUri.OriginalString.TrimStart('/')); 60 | 61 | request.RequestUri = newUri; 62 | 63 | HttpResponseMessage response = await instance.SendAsync(request, cancellationToken); 64 | 65 | response.EnsureSuccessStatusCode(); 66 | 67 | return response; 68 | }); 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/HttpCommunicationClient.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | using System; 9 | using System.Fabric; 10 | using Microsoft.ServiceFabric.Services.Communication.Client; 11 | 12 | /// 13 | /// Communication client that wraps the logic for talking to the service. 14 | /// Created by communication client factory. 15 | /// 16 | public class HttpCommunicationClient : ICommunicationClient 17 | { 18 | public HttpCommunicationClient(Uri baseAddress, string listenerName, TimeSpan operationTimeout, TimeSpan readWriteTimeout) 19 | { 20 | this.BaseAddress = baseAddress; 21 | this.ListenerName = listenerName; 22 | this.OperationTimeout = operationTimeout; 23 | this.ReadWriteTimeout = readWriteTimeout; 24 | } 25 | 26 | 27 | ///// 28 | ///// The service base address. 29 | ///// 30 | public Uri BaseAddress { get; private set; } 31 | 32 | public TimeSpan OperationTimeout { get; set; } 33 | 34 | public TimeSpan ReadWriteTimeout { get; set; } 35 | 36 | public ResolvedServiceEndpoint Endpoint { get; set; } 37 | 38 | public string ListenerName { get; set; } 39 | 40 | public ResolvedServicePartition ResolvedServicePartition { get; set; } 41 | } 42 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/HttpCommunicationClientFactory.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | using System; 9 | using System.Threading; 10 | using System.Threading.Tasks; 11 | using Microsoft.ServiceFabric.Services.Client; 12 | using Microsoft.ServiceFabric.Services.Communication.Client; 13 | 14 | /// 15 | /// Factory that creates clients that know to communicate with the WordCount service. 16 | /// Contains a service partition resolver that resolves a partition key 17 | /// and sets BaseAddress to the address of the replica that should serve a request. 18 | /// 19 | public class HttpCommunicationClientFactory : CommunicationClientFactoryBase 20 | { 21 | private TimeSpan OperationTimeout; 22 | private TimeSpan ReadWriteTimeout; 23 | private string EndpointName; 24 | 25 | public HttpCommunicationClientFactory(ServicePartitionResolver resolver, string endpointName, TimeSpan operationTimeout, TimeSpan readWriteTimeout) 26 | : base(resolver, null, null) 27 | { 28 | this.OperationTimeout = operationTimeout; 29 | this.ReadWriteTimeout = readWriteTimeout; 30 | this.EndpointName = endpointName; 31 | } 32 | 33 | protected override void AbortClient(HttpCommunicationClient client) 34 | { 35 | return; 36 | } 37 | 38 | protected override Task CreateClientAsync(string endpoint, CancellationToken cancellationToken) 39 | { 40 | // Create a communication client. This doesn't establish a session with the server. 41 | HttpCommunicationClient client = new HttpCommunicationClient(new Uri(endpoint), this.EndpointName, this.OperationTimeout, this.ReadWriteTimeout); 42 | 43 | if (this.ValidateClient(endpoint, client)) 44 | { 45 | return Task.FromResult(client); 46 | } 47 | else 48 | { 49 | throw new ArgumentException("Error creating HttpCommunicationClient, bad endpoint format"); 50 | } 51 | } 52 | 53 | protected override bool ValidateClient(HttpCommunicationClient client) 54 | { 55 | return true; 56 | } 57 | 58 | protected override bool ValidateClient(string endpoint, HttpCommunicationClient client) 59 | { 60 | if (string.IsNullOrEmpty(endpoint) || !endpoint.StartsWith("http")) 61 | { 62 | return false; 63 | } 64 | 65 | return true; 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/HttpCommunicationListener.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace Web.Service 7 | { 8 | using System; 9 | using System.Fabric; 10 | using System.Fabric.Description; 11 | using System.Globalization; 12 | using System.Threading; 13 | using System.Threading.Tasks; 14 | using Microsoft.Owin.Hosting; 15 | using Microsoft.ServiceFabric.Services.Communication.Runtime; 16 | 17 | public class HttpCommunicationListener : ICommunicationListener 18 | { 19 | private readonly IOwinAppBuilder startup; 20 | private readonly string appRoot; 21 | private readonly ServiceContext serviceContext; 22 | private IDisposable serverHandle; 23 | private string listeningAddress; 24 | 25 | public HttpCommunicationListener(string appRoot, IOwinAppBuilder startup, ServiceContext serviceInitializationParameters) 26 | { 27 | this.startup = startup; 28 | this.appRoot = appRoot; 29 | this.serviceContext = serviceInitializationParameters; 30 | } 31 | 32 | public Task OpenAsync(CancellationToken cancellationToken) 33 | { 34 | EndpointResourceDescription serviceEndpoint = this.serviceContext.CodePackageActivationContext.GetEndpoint("ServiceEndpoint"); 35 | int port = serviceEndpoint.Port; 36 | 37 | if (this.serviceContext is StatefulServiceContext) 38 | { 39 | StatefulServiceContext statefulServiceContext = 40 | (StatefulServiceContext) this.serviceContext; 41 | 42 | this.listeningAddress = string.Format( 43 | CultureInfo.InvariantCulture, 44 | "http://+:{0}/{1}/{2}/{3}", 45 | port, 46 | statefulServiceContext.PartitionId, 47 | statefulServiceContext.ReplicaId, 48 | Guid.NewGuid().ToString() + '/'); 49 | } 50 | else if (this.serviceContext is StatelessServiceContext) 51 | { 52 | this.listeningAddress = string.Format( 53 | CultureInfo.InvariantCulture, 54 | "http://+:{0}/{1}", 55 | port, 56 | string.IsNullOrWhiteSpace(this.appRoot) 57 | ? string.Empty 58 | : this.appRoot.TrimEnd('/') + '/'); 59 | } 60 | else 61 | { 62 | throw new InvalidOperationException(); 63 | } 64 | 65 | this.serverHandle = WebApp.Start(this.listeningAddress, appBuilder => this.startup.Configuration(appBuilder)); 66 | 67 | string resultAddress = this.listeningAddress.Replace("+", FabricRuntime.GetNodeContext().IPAddressOrFQDN); 68 | return Task.FromResult(resultAddress); 69 | } 70 | 71 | public Task CloseAsync(CancellationToken cancellationToken) 72 | { 73 | this.StopWebServer(); 74 | 75 | return Task.FromResult(true); 76 | } 77 | 78 | public void Abort() 79 | { 80 | this.StopWebServer(); 81 | } 82 | 83 | private void StopWebServer() 84 | { 85 | if (this.serverHandle != null) 86 | { 87 | try 88 | { 89 | this.serverHandle.Dispose(); 90 | } 91 | catch (ObjectDisposedException) 92 | { 93 | // no-op 94 | } 95 | } 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/IOwinAppBuilder.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace Web.Service 7 | { 8 | using Owin; 9 | 10 | public interface IOwinAppBuilder 11 | { 12 | void Configuration(IAppBuilder appBuilder); 13 | } 14 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/NationalStatsViewModel.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | using System; 9 | using System.Runtime.Serialization; 10 | 11 | [DataContract] 12 | public struct NationalStatsViewModel 13 | { 14 | public NationalStatsViewModel(int doctorCount, int patientCount, long healthReportCount, int averageHealthIndex, DateTimeOffset creationDateTime) 15 | { 16 | this.AverageHealthIndex = averageHealthIndex; 17 | this.DoctorCount = doctorCount; 18 | this.PatientCount = patientCount; 19 | this.HealthReportCount = healthReportCount; 20 | this.StartTimeOffset = creationDateTime; 21 | } 22 | 23 | [DataMember] 24 | public int DoctorCount { get; private set; } 25 | 26 | [DataMember] 27 | public int PatientCount { get; private set; } 28 | 29 | [DataMember] 30 | public long HealthReportCount { get; private set; } 31 | 32 | [DataMember] 33 | public int AverageHealthIndex { get; private set; } 34 | 35 | [DataMember] 36 | public DateTimeOffset StartTimeOffset { get; private set; } 37 | } 38 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | 13 | [assembly: AssemblyTitle("HealthMetrics.Common")] 14 | [assembly: AssemblyDescription("")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("")] 17 | [assembly: AssemblyProduct("HealthMetrics.Common")] 18 | [assembly: AssemblyCopyright("Copyright © 2015")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | 28 | // The following GUID is for the ID of the typelib if this project is exposed to COM 29 | 30 | [assembly: Guid("666742e6-38af-4012-a4a6-bcfbf28f29ee")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | 43 | [assembly: AssemblyVersion("1.0.0.0")] 44 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /HealthMetrics.Common/ServicePrimer.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | using System; 9 | using System.Fabric; 10 | using System.Fabric.Description; 11 | using System.Fabric.Query; 12 | using System.Linq; 13 | using System.Threading; 14 | using System.Threading.Tasks; 15 | 16 | public class ServicePrimer 17 | { 18 | private static FabricClient fabricClient; 19 | private readonly TimeSpan interval = TimeSpan.FromSeconds(5); 20 | 21 | public ServicePrimer() 22 | { 23 | } 24 | 25 | protected FabricClient Client 26 | { 27 | get 28 | { 29 | if (fabricClient == null) 30 | { 31 | fabricClient = new FabricClient(); 32 | } 33 | 34 | return fabricClient; 35 | } 36 | } 37 | 38 | public async Task WaitForStatefulService(Uri serviceInstanceUri, CancellationToken token) 39 | { 40 | StatefulServiceDescription description = 41 | await this.Client.ServiceManager.GetServiceDescriptionAsync(serviceInstanceUri) as StatefulServiceDescription; 42 | 43 | int targetTotalReplicas = description.TargetReplicaSetSize; 44 | if (description.PartitionSchemeDescription is UniformInt64RangePartitionSchemeDescription) 45 | { 46 | targetTotalReplicas *= ((UniformInt64RangePartitionSchemeDescription) description.PartitionSchemeDescription).PartitionCount; 47 | } 48 | 49 | ServicePartitionList partitions = await this.Client.QueryManager.GetPartitionListAsync(serviceInstanceUri); 50 | int replicaTotal = 0; 51 | 52 | while (replicaTotal < targetTotalReplicas && !token.IsCancellationRequested) 53 | { 54 | await Task.Delay(this.interval); 55 | //ServiceEventSource.Current.ServiceMessage(this, "CountyService waiting for National Service to come up."); 56 | 57 | replicaTotal = 0; 58 | foreach (Partition partition in partitions) 59 | { 60 | ServiceReplicaList replicaList = await this.Client.QueryManager.GetReplicaListAsync(partition.PartitionInformation.Id); 61 | 62 | replicaTotal += replicaList.Count(x => x.ReplicaStatus == System.Fabric.Query.ServiceReplicaStatus.Ready); 63 | } 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/ServiceUriBuilder.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.Common 7 | { 8 | using System; 9 | using System.Fabric; 10 | 11 | public class ServiceUriBuilder 12 | { 13 | public ServiceUriBuilder(string serviceInstance) 14 | { 15 | this.ServiceInstance = serviceInstance; 16 | } 17 | 18 | public ServiceUriBuilder(string applicationInstance, string serviceInstance) 19 | { 20 | this.ApplicationInstance = applicationInstance; 21 | this.ServiceInstance = serviceInstance; 22 | } 23 | 24 | /// 25 | /// The name of the application instance that contains he service. 26 | /// 27 | public string ApplicationInstance { get; set; } 28 | 29 | /// 30 | /// The name of the service instance. 31 | /// 32 | public string ServiceInstance { get; set; } 33 | 34 | public Uri ToUri() 35 | { 36 | string applicationInstance = this.ApplicationInstance; 37 | 38 | if (String.IsNullOrEmpty(applicationInstance)) 39 | { 40 | try 41 | { 42 | // the ApplicationName property here automatically prepends "fabric:/" for us 43 | applicationInstance = FabricRuntime.GetActivationContext().ApplicationName.Replace("fabric:/", String.Empty); 44 | } 45 | catch (InvalidOperationException) 46 | { 47 | // FabricRuntime is not available. 48 | // This indicates that this is being called from somewhere outside the Service Fabric cluster. 49 | } 50 | } 51 | 52 | return new Uri("fabric:/" + applicationInstance + "/" + this.ServiceInstance); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /HealthMetrics.Common/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 | -------------------------------------------------------------------------------- /HealthMetrics.Common/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /HealthMetrics.CountyService/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 | -------------------------------------------------------------------------------- /HealthMetrics.CountyService/App_Start/FormatterConfig.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.CountyService 7 | { 8 | using System.Net.Http.Formatting; 9 | using Newtonsoft.Json; 10 | 11 | public static class FormatterConfig 12 | { 13 | public static void ConfigureFormatters(MediaTypeFormatterCollection formatters) 14 | { 15 | formatters.Remove(formatters.XmlFormatter); 16 | 17 | JsonSerializerSettings settings = formatters.JsonFormatter.SerializerSettings; 18 | settings.Formatting = Formatting.None; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /HealthMetrics.CountyService/App_Start/UnityConfig.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.CountyService 7 | { 8 | using HealthMetrics.Common; 9 | using Microsoft.Practices.Unity; 10 | using Microsoft.ServiceFabric.Data; 11 | using System.Web.Http; 12 | using Unity.WebApi; 13 | 14 | public static class UnityConfig 15 | { 16 | public static void RegisterComponents(HttpConfiguration config, IReliableStateManager objectManager, HealthIndexCalculator indexCalculator) 17 | { 18 | UnityContainer container = new UnityContainer(); 19 | 20 | container.RegisterType( 21 | new TransientLifetimeManager(), 22 | new InjectionConstructor(objectManager, indexCalculator)); 23 | 24 | container.RegisterType( 25 | new TransientLifetimeManager(), 26 | new InjectionConstructor(objectManager, indexCalculator)); 27 | 28 | config.DependencyResolver = new UnityDependencyResolver(container); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /HealthMetrics.CountyService/Controllers/CountyDoctorsController.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.CountyService 7 | { 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Threading; 12 | using System.Threading.Tasks; 13 | using System.Web.Http; 14 | using HealthMetrics.Common; 15 | using Microsoft.ServiceFabric.Data; 16 | using Microsoft.ServiceFabric.Data.Collections; 17 | 18 | /// 19 | /// Votes controller. 20 | /// 21 | public class CountyDoctorsController : ApiController 22 | { 23 | private const string DoctorServiceName = "DoctorActorService"; 24 | private readonly IReliableStateManager stateManager; 25 | private readonly HealthIndexCalculator indexCalculator; 26 | 27 | public CountyDoctorsController(IReliableStateManager stateManager, HealthIndexCalculator indexCalculator) 28 | { 29 | this.stateManager = stateManager; 30 | this.indexCalculator = indexCalculator; 31 | } 32 | 33 | /// 34 | /// Returns { DoctorId, DoctorName, HealthStatus } 35 | /// 36 | /// 37 | [HttpGet] 38 | [Route("county/doctors/{countyId}")] 39 | public async Task Get(int countyId) 40 | { 41 | IReliableDictionary countyHealth = 42 | await this.stateManager.GetOrAddAsync>( 43 | string.Format(Service.CountyHealthDictionaryName, countyId)); 44 | 45 | IList> doctors = new List>(); 46 | 47 | using (ITransaction tx = this.stateManager.CreateTransaction()) 48 | { 49 | IAsyncEnumerator> enumerator = (await countyHealth.CreateEnumerableAsync(tx)).GetAsyncEnumerator(); 50 | 51 | while (await enumerator.MoveNextAsync(CancellationToken.None)) 52 | { 53 | doctors.Add(enumerator.Current); 54 | } 55 | } 56 | 57 | var doctorInfo = doctors.Select( 58 | (x) => 59 | { 60 | return new 61 | { 62 | DoctorId = x.Key, 63 | DoctorName = x.Value.DoctorName, 64 | HealthStatus = x.Value.AverageHealthIndex 65 | }; 66 | }).OrderByDescending((x) => x.HealthStatus); 67 | 68 | return this.Ok(doctorInfo); 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /HealthMetrics.CountyService/Models/CountyDoctorStats.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.CountyService 7 | { 8 | using System.Runtime.Serialization; 9 | using HealthMetrics.Common; 10 | 11 | [DataContract] 12 | internal struct CountyDoctorStats 13 | { 14 | public CountyDoctorStats(int patientCount, long healthReportCount, string doctorName, HealthIndex averageHealthIndex) 15 | { 16 | this.PatientCount = patientCount; 17 | this.HealthReportCount = healthReportCount; 18 | this.AverageHealthIndex = averageHealthIndex; 19 | this.DoctorName = doctorName; 20 | } 21 | 22 | [DataMember] 23 | public string DoctorName { get; private set; } 24 | 25 | [DataMember] 26 | public int PatientCount { get; private set; } 27 | 28 | [DataMember] 29 | public long HealthReportCount { get; private set; } 30 | 31 | [DataMember] 32 | public HealthIndex AverageHealthIndex { get; private set; } 33 | } 34 | } -------------------------------------------------------------------------------- /HealthMetrics.CountyService/Models/HistogramData.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.CountyService.Models 7 | { 8 | using System.Runtime.Serialization; 9 | 10 | [DataContract] 11 | public struct HistogramData 12 | { 13 | [DataMember] 14 | public string Bin { get; set; } 15 | 16 | [DataMember] 17 | public int Value { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /HealthMetrics.CountyService/PackageRoot/Config/Settings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 |
4 | 5 | 6 |
7 |
8 | 9 |
10 |
-------------------------------------------------------------------------------- /HealthMetrics.CountyService/PackageRoot/ServiceManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | HealthMetrics.CountyService.exe 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /HealthMetrics.CountyService/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | 13 | [assembly: AssemblyTitle("HealthMetrics.CountyService")] 14 | [assembly: AssemblyDescription("")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("")] 17 | [assembly: AssemblyProduct("HealthMetrics.CountyService")] 18 | [assembly: AssemblyCopyright("Copyright © 2015")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | 28 | // The following GUID is for the ID of the typelib if this project is exposed to COM 29 | 30 | [assembly: Guid("e942e745-587f-4feb-b67e-92ccd79327ca")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | 43 | [assembly: AssemblyVersion("1.0.0.0")] 44 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /HealthMetrics.CountyService/ServiceHost.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.CountyService 7 | { 8 | using System; 9 | using System.Diagnostics; 10 | using System.Net; 11 | using System.Threading; 12 | using Microsoft.ServiceFabric.Services.Runtime; 13 | 14 | public class ServiceHost 15 | { 16 | public static void Main(string[] args) 17 | { 18 | try 19 | { 20 | ServicePointManager.DefaultConnectionLimit = 10240; 21 | ServiceRuntime.RegisterServiceAsync(Service.ServiceTypeName, context => new Service(context)).GetAwaiter().GetResult(); 22 | 23 | ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, Service.ServiceTypeName); 24 | 25 | Thread.Sleep(Timeout.Infinite); 26 | } 27 | catch (Exception e) 28 | { 29 | Trace.WriteLine(e); 30 | ServiceEventSource.Current.ServiceHostInitializationFailed(e); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /HealthMetrics.CountyService/Startup.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.CountyService 7 | { 8 | using System.Web.Http; 9 | using HealthMetrics.Common; 10 | using Microsoft.ServiceFabric.Data; 11 | using Owin; 12 | using Web.Service; 13 | 14 | /// 15 | /// OWIN configuration 16 | /// 17 | public class Startup : IOwinAppBuilder 18 | { 19 | private readonly IReliableStateManager objectManager; 20 | private readonly HealthIndexCalculator indexCalculator; 21 | 22 | public Startup(IReliableStateManager objectManager, HealthIndexCalculator indexCalculator) 23 | { 24 | this.objectManager = objectManager; 25 | this.indexCalculator = indexCalculator; 26 | } 27 | 28 | /// 29 | /// Configures the app builder using Web API. 30 | /// 31 | /// 32 | public void Configuration(IAppBuilder appBuilder) 33 | { 34 | HttpConfiguration config = new HttpConfiguration(); 35 | 36 | config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; 37 | config.MapHttpAttributeRoutes(); 38 | 39 | FormatterConfig.ConfigureFormatters(config.Formatters); 40 | UnityConfig.RegisterComponents(config, this.objectManager, this.indexCalculator); 41 | 42 | appBuilder.UseWebApi(config); 43 | config.EnsureInitialized(); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /HealthMetrics.CountyService/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor.Interfaces/DoctorStatsViewModel.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.DoctorActor.Interfaces 7 | { 8 | using System.Runtime.Serialization; 9 | using HealthMetrics.Common; 10 | 11 | [DataContract] 12 | public struct DoctorStatsViewModel 13 | { 14 | public DoctorStatsViewModel(int patientCount, long healthReportCount, HealthIndex averageHealthIndex, string doctorName) 15 | { 16 | this.PatientCount = patientCount; 17 | this.HealthReportCount = healthReportCount; 18 | this.AverageHealthIndex = averageHealthIndex; 19 | this.DoctorName = doctorName; 20 | } 21 | 22 | [DataMember] 23 | public int PatientCount { get; private set; } 24 | 25 | [DataMember] 26 | public long HealthReportCount { get; private set; } 27 | 28 | [DataMember] 29 | public HealthIndex AverageHealthIndex { get; private set; } 30 | 31 | [DataMember] 32 | public string DoctorName { get; private set; } 33 | } 34 | } -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor.Interfaces/IDoctorActor.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.DoctorActor.Interfaces 7 | { 8 | using System; 9 | using System.Threading.Tasks; 10 | using HealthMetrics.Common; 11 | using Microsoft.ServiceFabric.Actors; 12 | 13 | public interface IDoctorActor : IActor 14 | { 15 | Task ReportHealthAsync(Guid personId, string personName, HealthIndex healthIndex); 16 | 17 | Task NewAsync(string name, CountyRecord countyRecord); 18 | 19 | //Task GetPatientsAsync(); 20 | 21 | Task> GetInfoAndNameAsync(); 22 | } 23 | } -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor.Interfaces/PatientDataViewModel.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.DoctorActor.Interfaces 7 | { 8 | using System; 9 | using System.Runtime.Serialization; 10 | using HealthMetrics.Common; 11 | 12 | [DataContract] 13 | public struct PatientDataViewModel 14 | { 15 | public PatientDataViewModel( 16 | Guid patientId, 17 | string name, 18 | HealthIndex healthIndex) 19 | { 20 | this.PatientId = patientId; 21 | this.PatientName = name; 22 | this.HealthIndex = healthIndex; 23 | } 24 | 25 | [DataMember] 26 | public Guid PatientId { get; private set; } 27 | 28 | [DataMember] 29 | public string PatientName { get; private set; } 30 | 31 | [DataMember] 32 | public HealthIndex HealthIndex { get; private set; } 33 | } 34 | } -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor.Interfaces/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | 13 | [assembly: AssemblyTitle("HealthMetrics.DoctorActor.Interfaces")] 14 | [assembly: AssemblyDescription("")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("")] 17 | [assembly: AssemblyProduct("HealthMetrics.DoctorActor.Interfaces")] 18 | [assembly: AssemblyCopyright("Copyright © 2015")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | 28 | // The following GUID is for the ID of the typelib if this project is exposed to COM 29 | 30 | [assembly: Guid("f945dafd-5424-49ca-95f1-360970ea9e31")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | 43 | [assembly: AssemblyVersion("1.0.0.0")] 44 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor.Interfaces/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor.Interfaces/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor/ActorEventSource.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.DoctorActor 7 | { 8 | using System; 9 | using System.Diagnostics.Tracing; 10 | using System.Fabric; 11 | using Microsoft.ServiceFabric.Actors.Runtime; 12 | 13 | [EventSource(Name = "MyCompany-HealthMetrics-HealthMetrics.DoctorActor")] 14 | internal sealed class ActorEventSource : EventSource 15 | { 16 | private const int MessageEventId = 1; 17 | 18 | private const int ActorMessageEventId = 2; 19 | 20 | private const int ActorHostInitializationFailedEventId = 3; 21 | public static readonly ActorEventSource Current = new ActorEventSource(); 22 | 23 | [NonEvent] 24 | public void Message(string message, params object[] args) 25 | { 26 | if (this.IsEnabled()) 27 | { 28 | string finalMessage = string.Format(message, args); 29 | this.Message(finalMessage); 30 | } 31 | } 32 | 33 | [Event(MessageEventId, Level = EventLevel.Informational, Message = "{0}")] 34 | public void Message(string message) 35 | { 36 | if (this.IsEnabled()) 37 | { 38 | this.WriteEvent(MessageEventId, message); 39 | } 40 | } 41 | 42 | [NonEvent] 43 | public void ActorMessage(Actor actor, string message, params object[] args) 44 | { 45 | if (this.IsEnabled()) 46 | { 47 | string finalMessage = string.Format(message, args); 48 | this.ActorMessage( 49 | actor.GetType().ToString(), 50 | actor.Id.ToString(), 51 | actor.ActorService.Context.CodePackageActivationContext.ApplicationTypeName, 52 | actor.ActorService.Context.CodePackageActivationContext.ApplicationName, 53 | actor.ActorService.Context.ServiceTypeName, 54 | actor.ActorService.Context.ServiceName.ToString(), 55 | actor.ActorService.Context.PartitionId, 56 | actor.ActorService.Context.ReplicaId, 57 | FabricRuntime.GetNodeContext().NodeName, 58 | finalMessage); 59 | } 60 | } 61 | 62 | [NonEvent] 63 | public void ActorHostInitializationFailed(Exception e) 64 | { 65 | if (this.IsEnabled()) 66 | { 67 | this.ActorHostInitializationFailed(e.ToString()); 68 | } 69 | } 70 | 71 | [Event(ActorMessageEventId, Level = EventLevel.Informational, Message = "{9}")] 72 | private 73 | void ActorMessage( 74 | string actorType, 75 | string actorId, 76 | string applicationTypeName, 77 | string applicationName, 78 | string serviceTypeName, 79 | string serviceName, 80 | Guid partitionId, 81 | long replicaOrInstanceId, 82 | string nodeName, 83 | string message) 84 | { 85 | this.WriteEvent( 86 | ActorMessageEventId, 87 | actorType, 88 | actorId, 89 | applicationTypeName, 90 | applicationName, 91 | serviceTypeName, 92 | serviceName, 93 | partitionId, 94 | replicaOrInstanceId, 95 | nodeName, 96 | message); 97 | } 98 | 99 | [Event(ActorHostInitializationFailedEventId, Level = EventLevel.Error, Message = "Actor host initialization failed")] 100 | private void ActorHostInitializationFailed(string exception) 101 | { 102 | this.WriteEvent(ActorHostInitializationFailedEventId, exception); 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor/DoctorPatientState.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.DoctorActor 7 | { 8 | using System; 9 | using System.Runtime.Serialization; 10 | using HealthMetrics.Common; 11 | 12 | [DataContract] 13 | internal struct DoctorPatientState 14 | { 15 | public DoctorPatientState(Guid id, string name, HealthIndex healthIndex) 16 | { 17 | this.Id = id; 18 | this.Name = name; 19 | this.HealthIndex = healthIndex; 20 | } 21 | 22 | [DataMember] 23 | public Guid Id { get; private set; } 24 | 25 | [DataMember] 26 | public string Name { get; private set; } 27 | 28 | [DataMember] 29 | public HealthIndex HealthIndex { get; private set; } 30 | } 31 | } -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor/PackageRoot/Config/Settings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 |
4 | 5 | 6 |
7 |
8 | 9 |
10 |
11 | 12 | 13 |
14 |
15 | 16 |
17 |
-------------------------------------------------------------------------------- /HealthMetrics.DoctorActor/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 | HealthMetrics.DoctorActor.exe 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | 13 | [assembly: AssemblyTitle("HealthMetrics.DoctorActor")] 14 | [assembly: AssemblyDescription("")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("")] 17 | [assembly: AssemblyProduct("HealthMetrics.DoctorActor")] 18 | [assembly: AssemblyCopyright("Copyright © 2015")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | 28 | // The following GUID is for the ID of the typelib if this project is exposed to COM 29 | 30 | [assembly: Guid("eead2ef9-3cd3-4c3b-93fe-09e309b1114d")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | 43 | [assembly: AssemblyVersion("1.0.0.0")] 44 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor/ServiceHost.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.DoctorActor 7 | { 8 | using System; 9 | using System.Threading; 10 | using Microsoft.ServiceFabric.Actors.Runtime; 11 | 12 | public class ServiceHost 13 | { 14 | public static void Main(string[] args) 15 | { 16 | try 17 | { 18 | ActorRuntime.RegisterActorAsync(); 19 | 20 | Thread.Sleep(Timeout.Infinite); 21 | } 22 | catch (Exception e) 23 | { 24 | ActorEventSource.Current.ActorHostInitializationFailed(e); 25 | throw; 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /HealthMetrics.DoctorActor/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /HealthMetrics.NationalService/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 | -------------------------------------------------------------------------------- /HealthMetrics.NationalService/App_Start/FormatterConfig.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.NationalService 7 | { 8 | using System.Net.Http.Formatting; 9 | using Newtonsoft.Json; 10 | 11 | public static class FormatterConfig 12 | { 13 | public static void ConfigureFormatters(MediaTypeFormatterCollection formatters) 14 | { 15 | formatters.Remove(formatters.XmlFormatter); 16 | 17 | JsonSerializerSettings settings = formatters.JsonFormatter.SerializerSettings; 18 | settings.Formatting = Formatting.None; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /HealthMetrics.NationalService/App_Start/UnityConfig.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.NationalService 7 | { 8 | using Microsoft.Practices.Unity; 9 | using Microsoft.ServiceFabric.Data; 10 | using System.Collections.Concurrent; 11 | using System.Web.Http; 12 | using Unity.WebApi; 13 | 14 | public static class UnityConfig 15 | { 16 | public static void RegisterComponents(HttpConfiguration config, IReliableStateManager objectManager, ConcurrentBag updatedCounties) 17 | { 18 | UnityContainer container = new UnityContainer(); 19 | 20 | container.RegisterType( 21 | new TransientLifetimeManager(), 22 | new InjectionConstructor(objectManager, updatedCounties)); 23 | 24 | container.RegisterType( 25 | new TransientLifetimeManager(), 26 | new InjectionConstructor(objectManager)); 27 | 28 | config.DependencyResolver = new UnityDependencyResolver(container); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /HealthMetrics.NationalService/Controllers/NationalStatsController.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.NationalService 7 | { 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Threading; 11 | using System.Threading.Tasks; 12 | using System.Web.Http; 13 | using HealthMetrics.Common; 14 | using HealthMetrics.NationalService.Models; 15 | using Microsoft.ServiceFabric.Data; 16 | using Microsoft.ServiceFabric.Data.Collections; 17 | 18 | /// 19 | /// Votes controller. 20 | /// 21 | public class NationalStatsController : ApiController 22 | { 23 | private const string HealthStatusDictionary = "healthStatusDictionary"; 24 | private const string TimeStatsDictionary = "TimeTracker"; 25 | 26 | private readonly IReliableStateManager stateManager; 27 | 28 | public NationalStatsController(IReliableStateManager stateManager) 29 | { 30 | this.stateManager = stateManager; 31 | } 32 | 33 | /// 34 | /// GET /votes/counties 35 | /// 36 | /// 37 | [HttpGet] 38 | [Route("national/stats")] 39 | public async Task Get() 40 | { 41 | IReliableDictionary dictionary = 42 | await this.stateManager.GetOrAddAsync>(HealthStatusDictionary); 43 | IReliableDictionary timeDictionary = 44 | await this.stateManager.GetOrAddAsync>(TimeStatsDictionary); 45 | 46 | int totalDoctorCount = 0; 47 | int totalPatientCount = 0; 48 | long totalHealthReportCount = 0; 49 | DateTimeOffset offset = DateTimeOffset.MinValue; 50 | 51 | using (ITransaction tx = this.stateManager.CreateTransaction()) 52 | { 53 | ConditionalValue creationTimeResult = await timeDictionary.TryGetValueAsync(tx, "StartTime"); 54 | 55 | if (creationTimeResult.HasValue) 56 | { 57 | offset = creationTimeResult.Value; 58 | } 59 | 60 | IAsyncEnumerator> enumerator = (await dictionary.CreateEnumerableAsync(tx)).GetAsyncEnumerator(); 61 | 62 | while (await enumerator.MoveNextAsync(CancellationToken.None)) 63 | { 64 | IList> items = new List>(); 65 | items.Add(enumerator.Current); 66 | 67 | foreach (KeyValuePair item in items) 68 | { 69 | totalDoctorCount += item.Value.DoctorCount; 70 | totalPatientCount += item.Value.PatientCount; 71 | totalHealthReportCount += item.Value.HealthReportCount; 72 | } 73 | } 74 | 75 | return new NationalStatsViewModel(totalDoctorCount, totalPatientCount, totalHealthReportCount, 0, offset); 76 | } 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /HealthMetrics.NationalService/Models/CountyHealth.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.NationalService.Models 7 | { 8 | using System.Runtime.Serialization; 9 | using HealthMetrics.Common; 10 | 11 | [DataContract] 12 | public struct CountyHealth 13 | { 14 | [DataMember] 15 | public int Id { get; set; } 16 | 17 | [DataMember] 18 | public HealthIndex Health { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /HealthMetrics.NationalService/Models/NationalCountyStats.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.NationalService.Models 7 | { 8 | using System.Runtime.Serialization; 9 | using HealthMetrics.Common; 10 | 11 | [DataContract] 12 | internal struct NationalCountyStats 13 | { 14 | public NationalCountyStats(int doctorCount, int patientCount, long healthReportCount, HealthIndex averageHealthIndex) 15 | { 16 | this.AverageHealthIndex = averageHealthIndex; 17 | this.DoctorCount = doctorCount; 18 | this.PatientCount = patientCount; 19 | this.HealthReportCount = healthReportCount; 20 | } 21 | 22 | [DataMember] 23 | public int DoctorCount { get; private set; } 24 | 25 | [DataMember] 26 | public int PatientCount { get; private set; } 27 | 28 | [DataMember] 29 | public long HealthReportCount { get; private set; } 30 | 31 | [DataMember] 32 | public HealthIndex AverageHealthIndex { get; private set; } 33 | } 34 | } -------------------------------------------------------------------------------- /HealthMetrics.NationalService/Models/VoteTotals.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Election.Common; 7 | 8 | namespace Election.NationalService.Models 9 | { 10 | public struct VoteTotals 11 | { 12 | public VoteTotals(IDictionary candidateTotals, IDictionary countyWinners) 13 | { 14 | this.CandidatesTotals = candidateTotals; 15 | this.CountyWinners = countyWinners; 16 | } 17 | 18 | public IDictionary CandidatesTotals { get; private set; } 19 | 20 | public IDictionary CountyWinners { get; private set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /HealthMetrics.NationalService/PackageRoot/Config/Settings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /HealthMetrics.NationalService/PackageRoot/ServiceManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | HealthMetrics.NationalService.exe 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /HealthMetrics.NationalService/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | 13 | [assembly: AssemblyTitle("HealthMetrics.NationalService")] 14 | [assembly: AssemblyDescription("")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("")] 17 | [assembly: AssemblyProduct("HealthMetrics.NationalService")] 18 | [assembly: AssemblyCopyright("Copyright © 2015")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | 28 | // The following GUID is for the ID of the typelib if this project is exposed to COM 29 | 30 | [assembly: Guid("c1f3336a-ed57-4009-8e75-3c3686b5c81c")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | 43 | [assembly: AssemblyVersion("1.0.0.0")] 44 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /HealthMetrics.NationalService/ServiceHost.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.NationalService 7 | { 8 | using System; 9 | using System.Diagnostics; 10 | using System.Net; 11 | using System.Threading; 12 | using Microsoft.ServiceFabric.Services.Runtime; 13 | 14 | public class ServiceHost 15 | { 16 | public static void Main(string[] args) 17 | { 18 | try 19 | { 20 | ServicePointManager.DefaultConnectionLimit = 10240; 21 | 22 | ServiceRuntime.RegisterServiceAsync(Service.ServiceTypeName, context => new Service(context)).GetAwaiter().GetResult(); 23 | 24 | ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, Service.ServiceTypeName); 25 | 26 | Thread.Sleep(Timeout.Infinite); 27 | } 28 | catch (Exception e) 29 | { 30 | ServiceEventSource.Current.ServiceHostInitializationFailed(e); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /HealthMetrics.NationalService/Startup.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.NationalService 7 | { 8 | using System.Collections.Concurrent; 9 | using System.Web.Http; 10 | using Microsoft.ServiceFabric.Data; 11 | using Owin; 12 | using Web.Service; 13 | 14 | /// 15 | /// OWIN configuration 16 | /// 17 | public class Startup : IOwinAppBuilder 18 | { 19 | private readonly IReliableStateManager objectManager; 20 | private readonly ConcurrentBag updatedCounties; 21 | 22 | public Startup(IReliableStateManager objectManager, ConcurrentBag updatedCounties) 23 | { 24 | this.objectManager = objectManager; 25 | this.updatedCounties = updatedCounties; 26 | } 27 | 28 | /// 29 | /// Configures the app builder using Web API. 30 | /// 31 | /// 32 | public void Configuration(IAppBuilder appBuilder) 33 | { 34 | HttpConfiguration config = new HttpConfiguration(); 35 | 36 | config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; 37 | config.MapHttpAttributeRoutes(); 38 | 39 | FormatterConfig.ConfigureFormatters(config.Formatters); 40 | UnityConfig.RegisterComponents(config, this.objectManager, this.updatedCounties); 41 | 42 | appBuilder.UseWebApi(config); 43 | 44 | config.EnsureInitialized(); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /HealthMetrics.NationalService/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /HealthMetrics.WebService/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 | -------------------------------------------------------------------------------- /HealthMetrics.WebService/App_Start/FormatterConfig.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.WebService 7 | { 8 | using System.Net.Http.Formatting; 9 | using Newtonsoft.Json; 10 | 11 | public static class FormatterConfig 12 | { 13 | public static void ConfigureFormatters(MediaTypeFormatterCollection formatters) 14 | { 15 | formatters.Remove(formatters.XmlFormatter); 16 | 17 | JsonSerializerSettings settings = formatters.JsonFormatter.SerializerSettings; 18 | settings.Formatting = Formatting.None; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /HealthMetrics.WebService/App_Start/UnityConfig.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.WebService 7 | { 8 | using HealthMetrics.WebService.Controllers; 9 | using Microsoft.Practices.Unity; 10 | using System.Fabric; 11 | using System.Web.Http; 12 | using Unity.WebApi; 13 | 14 | public static class UnityConfig 15 | { 16 | public static void RegisterComponents(HttpConfiguration config, ServiceContext serviceContext) 17 | { 18 | UnityContainer container = new UnityContainer(); 19 | 20 | container.RegisterType( 21 | new TransientLifetimeManager(), 22 | new InjectionConstructor(serviceContext.CodePackageActivationContext.GetConfigurationPackageObject("Config").Settings)); 23 | 24 | 25 | config.DependencyResolver = new UnityDependencyResolver(container); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /HealthMetrics.WebService/PackageRoot/Config/Settings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /HealthMetrics.WebService/PackageRoot/ServiceManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | HealthMetrics.WebService.exe 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HealthMetrics.WebService/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | 13 | [assembly: AssemblyTitle("HealthMetrics.WebService")] 14 | [assembly: AssemblyDescription("")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("")] 17 | [assembly: AssemblyProduct("HealthMetrics.WebService")] 18 | [assembly: AssemblyCopyright("Copyright © 2015")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | 28 | // The following GUID is for the ID of the typelib if this project is exposed to COM 29 | 30 | [assembly: Guid("70441db0-519f-49ed-bad5-5835aac60af1")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | 43 | [assembly: AssemblyVersion("1.0.0.0")] 44 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/d3/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010-2017 Mike Bostock 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of contributors may be used to 15 | endorse or promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/d3/README.md: -------------------------------------------------------------------------------- 1 | # D3: Data-Driven Documents 2 | 3 | 4 | 5 | **D3** (or **D3.js**) is a JavaScript library for visualizing data using web standards. D3 helps you bring data to life using SVG, Canvas and HTML. D3 combines powerful visualization and interaction techniques with a data-driven approach to DOM manipulation, giving you the full capabilities of modern browsers and the freedom to design the right visual interface for your data. 6 | 7 | ## Resources 8 | 9 | * [API Reference](https://github.com/d3/d3/blob/master/API.md) 10 | * [Release Notes](https://github.com/d3/d3/releases) 11 | * [Gallery](https://github.com/d3/d3/wiki/Gallery) 12 | * [Examples](https://bl.ocks.org/mbostock) 13 | * [Wiki](https://github.com/d3/d3/wiki) 14 | 15 | ## Installing 16 | 17 | If you use npm, `npm install d3`. Otherwise, download the [latest release](https://github.com/d3/d3/releases/latest). The released bundle supports anonymous AMD, CommonJS, and vanilla environments. You can load directly from [d3js.org](https://d3js.org), [CDNJS](https://cdnjs.com/libraries/d3), or [unpkg](https://unpkg.com/d3/). For example: 18 | 19 | ```html 20 | 21 | ``` 22 | 23 | For the minified version: 24 | 25 | ```html 26 | 27 | ``` 28 | 29 | You can also use the standalone D3 microlibraries. For example, [d3-selection](https://github.com/d3/d3-selection): 30 | 31 | ```html 32 | 33 | ``` 34 | 35 | D3 is written using [ES2015 modules](http://www.2ality.com/2014/09/es6-modules-final.html). Create a [custom bundle using Rollup](https://bl.ocks.org/mbostock/bb09af4c39c79cffcde4), Webpack, or your preferred bundler. To import D3 into an ES2015 application, either import specific symbols from specific D3 modules: 36 | 37 | ```js 38 | import {scaleLinear} from "d3-scale"; 39 | ``` 40 | 41 | Or import everything into a namespace (here, `d3`): 42 | 43 | ```js 44 | import * as d3 from "d3"; 45 | ``` 46 | 47 | In Node: 48 | 49 | ```js 50 | var d3 = require("d3"); 51 | ``` 52 | 53 | You can also require individual modules and combine them into a `d3` object using [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign): 54 | 55 | ```js 56 | var d3 = Object.assign({}, require("d3-format"), require("d3-geo"), require("d3-geo-projection")); 57 | ``` 58 | -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Title: MIT License 2 | 3 | Copyright (c) 2009-2013 Chris Leonello 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/README.txt: -------------------------------------------------------------------------------- 1 | Title: jqPlot Readme 2 | 3 | Pure JavaScript plotting plugin for jQuery. 4 | 5 | To learn how to use jqPlot, start with the Basic Usage Instructions below. Then read the 6 | usage.txt and jqPlotOptions.txt files included with the distribution. 7 | 8 | The jqPlot home page is at . 9 | 10 | Downloads can be found at . 11 | 12 | The mailing list is at . 13 | 14 | Examples and unit tests are at . 15 | 16 | Documentation is at . 17 | 18 | The project page and source code are at . 19 | 20 | Bugs, issues, feature requests: . 21 | 22 | Basic Usage Instructions: 23 | 24 | jqPlot requires jQuery (1.4+ required for certain features). jQuery 1.9.1 is included in 25 | the distribution. To use jqPlot include jQuery, the jqPlot jQuery plugin, the jqPlot css file and 26 | optionally the excanvas script to support IE version prior to IE 9 in your web page: 27 | 28 | > 29 | > 30 | > 31 | > 32 | 33 | For usage instructions, see in usage.txt. For available options, see 34 | in jqPlotOptions.txt. 35 | 36 | Building from source: 37 | 38 | If you've cloned the repository, you can build a distribution from source. 39 | You need to have ant installed. You can simply 40 | type "ant" from the jqplot directory to build the default "all" target. 41 | There are 6 pertinent targets: clean, dist, min, docs, compress and all. Use: 42 | 43 | > ant -p 44 | 45 | to get a description of the various build targets. 46 | 47 | Legal Notices: 48 | 49 | Copyright (c) 2009-2013 Chris Leonello 50 | jqPlot is currently available for use in all personal or commercial projects 51 | under both the MIT and GPL version 2.0 licenses. This means that you can 52 | choose the license that best suits your project and use it accordingly. 53 | 54 | Although not required, the author would appreciate an email letting him 55 | know of any substantial use of jqPlot. You can reach the author at: 56 | chris at jqplot or see http://www.jqplot.com/info.php . 57 | 58 | If you are feeling kind and generous, consider supporting the project by 59 | making a donation at: http://www.jqplot.com/donate.php . 60 | 61 | jqPlot includes date instance methods and printf/sprintf functions by other authors: 62 | 63 | Date instance methods: 64 | 65 | author Ken Snyder (ken d snyder at gmail dot com) 66 | date 2008-09-10 67 | version 2.0.2 (http://kendsnyder.com/sandbox/date/) 68 | license Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/) 69 | 70 | JavaScript printf/sprintf functions. 71 | 72 | version 2007.04.27 73 | author Ash Searle 74 | http://hexmen.com/blog/2007/03/printf-sprintf/ 75 | http://hexmen.com/js/sprintf.js 76 | The author (Ash Searle) has placed this code in the public domain: 77 | "This code is unrestricted: you are free to use it however you like." 78 | -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/copyright.txt: -------------------------------------------------------------------------------- 1 | /** 2 | * jqPlot 3 | * Pure JavaScript plotting plugin using jQuery 4 | * 5 | * Version: @VERSION 6 | * 7 | * Copyright (c) 2009-2013 Chris Leonello 8 | * jqPlot is currently available for use in all personal or commercial projects 9 | * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 10 | * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 11 | * choose the license that best suits your project and use it accordingly. 12 | * 13 | * Although not required, the author would appreciate an email letting him 14 | * know of any substantial use of jqPlot. You can reach the author at: 15 | * chris at jqplot dot com or see http://www.jqplot.com/info.php . 16 | * 17 | * If you are feeling kind and generous, consider supporting the project by 18 | * making a donation at: http://www.jqplot.com/donate.php . 19 | * 20 | * sprintf functions contained in jqplot.sprintf.js by Ash Searle: 21 | * 22 | * version 2007.04.27 23 | * author Ash Searle 24 | * http://hexmen.com/blog/2007/03/printf-sprintf/ 25 | * http://hexmen.com/js/sprintf.js 26 | * The author (Ash Searle) has placed this code in the public domain: 27 | * "This code is unrestricted: you are free to use it however you like." 28 | * 29 | * included jsDate library by Chris Leonello: 30 | * 31 | * Copyright (c) 2010-2013 Chris Leonello 32 | * 33 | * jsDate is currently available for use in all personal or commercial projects 34 | * under both the MIT and GPL version 2.0 licenses. This means that you can 35 | * choose the license that best suits your project and use it accordingly. 36 | * 37 | * jsDate borrows many concepts and ideas from the Date Instance 38 | * Methods by Ken Snyder along with some parts of Ken's actual code. 39 | * 40 | * Ken's origianl Date Instance Methods and copyright notice: 41 | * 42 | * Ken Snyder (ken d snyder at gmail dot com) 43 | * 2008-09-10 44 | * version 2.0.2 (http://kendsnyder.com/sandbox/date/) 45 | * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/) 46 | * 47 | * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js. 48 | * Larry has generously given permission to adapt his code for inclusion 49 | * into jqPlot. 50 | * 51 | * Larry's original code can be found here: 52 | * 53 | * https://github.com/lsiden/export-jqplot-to-png 54 | * 55 | * 56 | */ 57 | -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/jqPlotCssStyling.txt: -------------------------------------------------------------------------------- 1 | Title: jqPlot CSS Customization 2 | 3 | Much of the styling of jqPlot is done by css. The jqPlot css file is, unremarkably, 4 | jquery.jqplot.css and resides in the same directory as jqPlot itself. 5 | 6 | There exist some styling related javascript properties on the plot objects themselves 7 | (like fontStyle, fontSize, etc.). These can be set with the options object at plot creation. 8 | Generally, setting these options is *NOT* the preferred way to customize the look of the 9 | plot. Use the css file instead. *These options are deprecated and may disappear*. The 10 | exceptions are certain background and color options which control attributes of something 11 | renderered on a canvas. This would be line color, grid background, etc. These must 12 | be set by the options object. For a list of available options, see . 13 | 14 | Objects in the plot that can be customized by css are given a css class like ".jqplot-*". 15 | For example, the plot title will have a ".jqplot-title" class, the axes ".jqplot-axis", etc. 16 | 17 | Currently assigned classes in jqPlot 18 | are as follows: 19 | 20 | .jqplot-target - Styles for the plot target div. These will be cascaded down 21 | to all plot elements according to css rules. 22 | 23 | .jqplot-axis - Styles for all axes 24 | 25 | .jqplot-xaxis - Styles applied to the primary x axis only. 26 | 27 | .jqplot-yaxis - Styles applied to the primary y axis only. 28 | 29 | .jqplot-x2axis, .jqplot-x3axis, ... - Styles applied to the 2nd, 3rd, etc. x axis only. 30 | 31 | .jqplot-y2axis, .jqplot-y3axis, ... - Styles applied to the 2nd, 3rd, etc.y axis only. 32 | 33 | .jqplot-axis-tick - Styles applied to all axis ticks 34 | 35 | .jqplot-xaxis-tick - Styles applied to primary x axis ticks only. 36 | 37 | .jqplot-x2axis-tick - Styles applied to secondary x axis ticks only. 38 | 39 | .jqplot-yaxis-tick - Styles applied to primary y axis ticks only. 40 | 41 | .jqplot-y2axis-tick - Styles applied to secondary y axis ticks only. 42 | 43 | table.jqplot-table-legend - Styles applied to the legend box table. 44 | 45 | .jqplot-title - Styles applied to the title. 46 | 47 | .jqplot-cursor-tooltip - Styles applied to the cursor tooltip 48 | 49 | .jqplot-highlighter-tooltip - Styles applied to the highlighter tooltip. 50 | 51 | div.jqplot-table-legend-swatch - the div element used for the colored swatch on the legend. 52 | 53 | Note that axes will be assigned 2 classes like: class=".jqplot-axis .jqplot-xaxis". -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/jquery.jqplot.min.css: -------------------------------------------------------------------------------- 1 | .jqplot-target{position:relative;color:#666;font-family:"Trebuchet MS",Arial,Helvetica,sans-serif;font-size:1em}.jqplot-axis{font-size:.75em}.jqplot-xaxis{margin-top:10px}.jqplot-x2axis{margin-bottom:10px}.jqplot-yaxis{margin-right:10px}.jqplot-y2axis,.jqplot-y3axis,.jqplot-y4axis,.jqplot-y5axis,.jqplot-y6axis,.jqplot-y7axis,.jqplot-y8axis,.jqplot-y9axis,.jqplot-yMidAxis{margin-left:10px;margin-right:10px}.jqplot-axis-tick,.jqplot-xaxis-tick,.jqplot-yaxis-tick,.jqplot-x2axis-tick,.jqplot-y2axis-tick,.jqplot-y3axis-tick,.jqplot-y4axis-tick,.jqplot-y5axis-tick,.jqplot-y6axis-tick,.jqplot-y7axis-tick,.jqplot-y8axis-tick,.jqplot-y9axis-tick,.jqplot-yMidAxis-tick{position:absolute;white-space:pre}.jqplot-xaxis-tick{top:0;left:15px;vertical-align:top}.jqplot-x2axis-tick{bottom:0;left:15px;vertical-align:bottom}.jqplot-yaxis-tick{right:0;top:15px;text-align:right}.jqplot-yaxis-tick.jqplot-breakTick{right:-20px;margin-right:0;padding:1px 5px 1px 5px;z-index:2;font-size:1.5em}.jqplot-y2axis-tick,.jqplot-y3axis-tick,.jqplot-y4axis-tick,.jqplot-y5axis-tick,.jqplot-y6axis-tick,.jqplot-y7axis-tick,.jqplot-y8axis-tick,.jqplot-y9axis-tick{left:0;top:15px;text-align:left}.jqplot-yMidAxis-tick{text-align:center;white-space:nowrap}.jqplot-xaxis-label{margin-top:10px;font-size:11pt;position:absolute}.jqplot-x2axis-label{margin-bottom:10px;font-size:11pt;position:absolute}.jqplot-yaxis-label{margin-right:10px;font-size:11pt;position:absolute}.jqplot-yMidAxis-label{font-size:11pt;position:absolute}.jqplot-y2axis-label,.jqplot-y3axis-label,.jqplot-y4axis-label,.jqplot-y5axis-label,.jqplot-y6axis-label,.jqplot-y7axis-label,.jqplot-y8axis-label,.jqplot-y9axis-label{font-size:11pt;margin-left:10px;position:absolute}.jqplot-meterGauge-tick{font-size:.75em;color:#999}.jqplot-meterGauge-label{font-size:1em;color:#999}table.jqplot-table-legend{margin-top:12px;margin-bottom:12px;margin-left:12px;margin-right:12px}table.jqplot-table-legend,table.jqplot-cursor-legend{background-color:rgba(255,255,255,0.6);border:1px solid #ccc;position:absolute;font-size:.75em}td.jqplot-table-legend{vertical-align:middle}td.jqplot-seriesToggle:hover,td.jqplot-seriesToggle:active{cursor:pointer}.jqplot-table-legend .jqplot-series-hidden{text-decoration:line-through}div.jqplot-table-legend-swatch-outline{border:1px solid #ccc;padding:1px}div.jqplot-table-legend-swatch{width:0;height:0;border-top-width:5px;border-bottom-width:5px;border-left-width:6px;border-right-width:6px;border-top-style:solid;border-bottom-style:solid;border-left-style:solid;border-right-style:solid}.jqplot-title{top:0;left:0;padding-bottom:.5em;font-size:1.2em}table.jqplot-cursor-tooltip{border:1px solid #ccc;font-size:.75em}.jqplot-cursor-tooltip{border:1px solid #ccc;font-size:.75em;white-space:nowrap;background:rgba(208,208,208,0.5);padding:1px}.jqplot-highlighter-tooltip,.jqplot-canvasOverlay-tooltip{border:1px solid #ccc;font-size:.75em;white-space:nowrap;background:rgba(208,208,208,0.5);padding:1px}.jqplot-point-label{font-size:.75em;z-index:2}td.jqplot-cursor-legend-swatch{vertical-align:middle;text-align:center}div.jqplot-cursor-legend-swatch{width:1.2em;height:.7em}.jqplot-error{text-align:center}.jqplot-error-message{position:relative;top:46%;display:inline-block}div.jqplot-bubble-label{font-size:.8em;padding-left:2px;padding-right:2px;color:rgb(20%,20%,20%)}div.jqplot-bubble-label.jqplot-bubble-label-highlight{background:rgba(90%,90%,90%,0.7)}div.jqplot-noData-container{text-align:center;background-color:rgba(96%,96%,96%,0.3)} -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/plugins/jqplot.blockRenderer.min.js: -------------------------------------------------------------------------------- 1 | /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com 2 | jsDate | (c) 2010-2013 Chris Leonello 3 | */(function(a){a.jqplot.BlockRenderer=function(){a.jqplot.LineRenderer.call(this)};a.jqplot.BlockRenderer.prototype=new a.jqplot.LineRenderer();a.jqplot.BlockRenderer.prototype.constructor=a.jqplot.BlockRenderer;a.jqplot.BlockRenderer.prototype.init=function(b){this.css={padding:"2px",border:"1px solid #999",textAlign:"center"};this.escapeHtml=false;this.insertBreaks=true;this.varyBlockColors=false;a.extend(true,this,b);if(this.css.backgroundColor){this.color=this.css.backgroundColor}else{if(this.css.background){this.color=this.css.background}else{if(!this.varyBlockColors){this.css.background=this.color}}}this.canvas=new a.jqplot.BlockCanvas();this.shadowCanvas=new a.jqplot.BlockCanvas();this.canvas._plotDimensions=this._plotDimensions;this.shadowCanvas._plotDimensions=this._plotDimensions;this._type="block";this.moveBlock=function(l,j,i,e){var c=this.canvas._elem.children(":eq("+l+")");this.data[l][0]=j;this.data[l][1]=i;this._plotData[l][0]=j;this._plotData[l][1]=i;this._stackData[l][0]=j;this._stackData[l][1]=i;this.gridData[l][0]=this._xaxis.series_u2p(j);this.gridData[l][1]=this._yaxis.series_u2p(i);var k=c.outerWidth();var f=c.outerHeight();var d=this.gridData[l][0]-k/2+"px";var g=this.gridData[l][1]-f/2+"px";if(e){if(parseInt(e,10)){e=parseInt(e,10)}c.animate({left:d,top:g},e)}else{c.css({left:d,top:g})}c=null}};a.jqplot.BlockRenderer.prototype.draw=function(q,o,r){if(this.plugins.pointLabels){this.plugins.pointLabels.show=false}var f,c,l,o,p,k,n,g,e,m;var b=(r!=undefined)?r:{};var j=new a.jqplot.ColorGenerator(this.seriesColors);this.canvas._elem.empty();for(f=0;f")}k=a.extend(true,{},this.css,k);c=a('
');this.canvas._elem.append(c);this.escapeHtml?c.text(p):c.html(p);delete k.position;delete k.marginRight;delete k.marginLeft;if(!k.background&&!k.backgroundColor&&!k.backgroundImage){k.background=j.next()}c.css(k);n=c.outerWidth();g=c.outerHeight();e=o[0]-n/2+"px";m=o[1]-g/2+"px";c.css({left:e,top:m});c=null}};a.jqplot.BlockCanvas=function(){a.jqplot.ElemContainer.call(this);this._ctx};a.jqplot.BlockCanvas.prototype=new a.jqplot.ElemContainer();a.jqplot.BlockCanvas.prototype.constructor=a.jqplot.BlockCanvas;a.jqplot.BlockCanvas.prototype.createElement=function(i,e,c){this._offsets=i;var b="jqplot-blockCanvas";if(e!=undefined){b=e}var g;if(this._elem){g=this._elem.get(0)}else{g=document.createElement("div")}if(c!=undefined){this._plotDimensions=c}var d=this._plotDimensions.width-this._offsets.left-this._offsets.right+"px";var f=this._plotDimensions.height-this._offsets.top-this._offsets.bottom+"px";this._elem=a(g);this._elem.css({position:"absolute",width:d,height:f,left:this._offsets.left,top:this._offsets.top});this._elem.addClass(b);return this._elem};a.jqplot.BlockCanvas.prototype.setContext=function(){this._ctx={canvas:{width:0,height:0},clearRect:function(){return null}};return this._ctx}})(jQuery); -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/plugins/jqplot.canvasAxisLabelRenderer.min.js: -------------------------------------------------------------------------------- 1 | /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com 2 | jsDate | (c) 2010-2013 Chris Leonello 3 | */(function(a){a.jqplot.CanvasAxisLabelRenderer=function(b){this.angle=0;this.axis;this.show=true;this.showLabel=true;this.label="";this.fontFamily='"Trebuchet MS", Arial, Helvetica, sans-serif';this.fontSize="11pt";this.fontWeight="normal";this.fontStretch=1;this.textColor="#666666";this.enableFontSupport=true;this.pt2px=null;this._elem;this._ctx;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null};a.extend(true,this,b);if(b.angle==null&&this.axis!="xaxis"&&this.axis!="x2axis"){this.angle=-90}var c={fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily};if(this.pt2px){c.pt2px=this.pt2px}if(this.enableFontSupport){if(a.jqplot.support_canvas_text()){this._textRenderer=new a.jqplot.CanvasFontRenderer(c)}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}};a.jqplot.CanvasAxisLabelRenderer.prototype.init=function(b){a.extend(true,this,b);this._textRenderer.init({fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily})};a.jqplot.CanvasAxisLabelRenderer.prototype.getWidth=function(d){if(this._elem){return this._elem.outerWidth(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.sin(f.angle)*e)+Math.abs(Math.cos(f.angle)*c);return b}};a.jqplot.CanvasAxisLabelRenderer.prototype.getHeight=function(d){if(this._elem){return this._elem.outerHeight(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.cos(f.angle)*e)+Math.abs(Math.sin(f.angle)*c);return b}};a.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad=function(){var b=this.angle*Math.PI/180;return b};a.jqplot.CanvasAxisLabelRenderer.prototype.draw=function(c,f){if(this._elem){if(a.jqplot.use_excanvas&&window.G_vmlCanvasManager.uninitElement!==undefined){window.G_vmlCanvasManager.uninitElement(this._elem.get(0))}this._elem.emptyForce();this._elem=null}var e=f.canvasManager.getCanvas();this._textRenderer.setText(this.label,c);var b=this.getWidth(c);var d=this.getHeight(c);e.width=b;e.height=d;e.style.width=b;e.style.height=d;e=f.canvasManager.initCanvas(e);this._elem=a(e);this._elem.css({position:"absolute"});this._elem.addClass("jqplot-"+this.axis+"-label");e=null;return this._elem};a.jqplot.CanvasAxisLabelRenderer.prototype.pack=function(){this._textRenderer.draw(this._elem.get(0).getContext("2d"),this.label)}})(jQuery); -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/plugins/jqplot.canvasAxisTickRenderer.min.js: -------------------------------------------------------------------------------- 1 | /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com 2 | jsDate | (c) 2010-2013 Chris Leonello 3 | */(function(a){a.jqplot.CanvasAxisTickRenderer=function(b){this.mark="outside";this.showMark=true;this.showGridline=true;this.isMinorTick=false;this.angle=0;this.markSize=4;this.show=true;this.showLabel=true;this.labelPosition="auto";this.label="";this.value=null;this._styles={};this.formatter=a.jqplot.DefaultTickFormatter;this.formatString="";this.prefix="";this.fontFamily='"Trebuchet MS", Arial, Helvetica, sans-serif';this.fontSize="10pt";this.fontWeight="normal";this.fontStretch=1;this.textColor="#666666";this.enableFontSupport=true;this.pt2px=null;this._elem;this._ctx;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null};a.extend(true,this,b);var c={fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily};if(this.pt2px){c.pt2px=this.pt2px}if(this.enableFontSupport){if(a.jqplot.support_canvas_text()){this._textRenderer=new a.jqplot.CanvasFontRenderer(c)}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}};a.jqplot.CanvasAxisTickRenderer.prototype.init=function(b){a.extend(true,this,b);this._textRenderer.init({fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily})};a.jqplot.CanvasAxisTickRenderer.prototype.getWidth=function(d){if(this._elem){return this._elem.outerWidth(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.sin(f.angle)*e)+Math.abs(Math.cos(f.angle)*c);return b}};a.jqplot.CanvasAxisTickRenderer.prototype.getHeight=function(d){if(this._elem){return this._elem.outerHeight(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.cos(f.angle)*e)+Math.abs(Math.sin(f.angle)*c);return b}};a.jqplot.CanvasAxisTickRenderer.prototype.getTop=function(b){if(this._elem){return this._elem.position().top}else{return null}};a.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad=function(){var b=this.angle*Math.PI/180;return b};a.jqplot.CanvasAxisTickRenderer.prototype.setTick=function(b,d,c){this.value=b;if(c){this.isMinorTick=true}return this};a.jqplot.CanvasAxisTickRenderer.prototype.draw=function(c,f){if(!this.label){this.label=this.prefix+this.formatter(this.formatString,this.value)}if(this._elem){if(a.jqplot.use_excanvas&&window.G_vmlCanvasManager.uninitElement!==undefined){window.G_vmlCanvasManager.uninitElement(this._elem.get(0))}this._elem.emptyForce();this._elem=null}var e=f.canvasManager.getCanvas();this._textRenderer.setText(this.label,c);var b=this.getWidth(c);var d=this.getHeight(c);e.width=b;e.height=d;e.style.width=b;e.style.height=d;e.style.textAlign="left";e.style.position="absolute";e=f.canvasManager.initCanvas(e);this._elem=a(e);this._elem.css(this._styles);this._elem.addClass("jqplot-"+this.axis+"-tick");e=null;return this._elem};a.jqplot.CanvasAxisTickRenderer.prototype.pack=function(){this._textRenderer.draw(this._elem.get(0).getContext("2d"),this.label)}})(jQuery); -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/plugins/jqplot.ciParser.min.js: -------------------------------------------------------------------------------- 1 | /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com 2 | jsDate | (c) 2010-2013 Chris Leonello 3 | */(function(a){a.jqplot.ciParser=function(g,l){var m=[],o,n,h,f,e,c;if(typeof(g)=="string"){g=a.jqplot.JSON.parse(g,d)}else{if(typeof(g)=="object"){for(e in g){for(h=0;h=0){i=/^\/Date\((-?[0-9]+)\)\/$/.exec(k);if(i){return parseInt(i[1],10)}}return k}}for(var b in g){o=[];n=g[b];switch(b){case"PriceTicks":for(h=0;h=0.6)?l[3]*0.6:l[3]*(2-l[3]);m.color="rgba("+o[0]+","+o[1]+","+o[2]+","+k+")"}i.color=m.color;i.init();var g=(p.pointIndex>0)?p.pointIndex-1:0;var j=p.pointIndex+2;m._gridData=q.gridData.slice(g,j)}function e(o,l,h,t,m){if(m.plugins.dragable.dragCanvas.isDragging){var u=m.plugins.dragable.dragCanvas;var i=u._neighbor;var w=m.series[i.seriesIndex];var k=w.plugins.dragable;var r=w.gridData;var p=(k.constrainTo=="y")?i.gridData[0]:l.x;var n=(k.constrainTo=="x")?i.gridData[1]:l.y;var g=w._xaxis.series_p2u(p);var q=w._yaxis.series_p2u(n);var v=u._ctx;v.clearRect(0,0,v.canvas.width,v.canvas.height);if(i.pointIndex>0){k._gridData[1]=[p,n]}else{k._gridData[0]=[p,n]}m.series[i.seriesIndex].draw(u._ctx,{gridData:k._gridData,shadow:false,preventJqPlotSeriesDrawTrigger:true,color:k.color,markerOptions:{color:k.color,shadow:false},trendline:{show:false}});m.target.trigger("jqplotSeriesPointChange",[i.seriesIndex,i.pointIndex,[g,q],[p,n]])}else{if(t!=null){var j=m.series[t.seriesIndex];if(j.isDragable){var u=m.plugins.dragable.dragCanvas;if(!u.isOver){u._cursors.push(o.target.style.cursor);o.target.style.cursor="pointer"}u.isOver=true}}else{if(t==null){var u=m.plugins.dragable.dragCanvas;if(u.isOver){o.target.style.cursor=u._cursors.pop();u.isOver=false}}}}}function c(k,i,g,l,j){var m=j.plugins.dragable.dragCanvas;m._cursors.push(k.target.style.cursor);if(l!=null){var o=j.series[l.seriesIndex];var h=o.plugins.dragable;if(o.isDragable&&!m.isDragging){m._neighbor=l;m.isDragging=true;f(j,l);h.markerRenderer.draw(o.gridData[l.pointIndex][0],o.gridData[l.pointIndex][1],m._ctx);k.target.style.cursor="move";j.target.trigger("jqplotDragStart",[l.seriesIndex,l.pointIndex,i,g])}}else{var n=m._ctx;n.clearRect(0,0,n.canvas.width,n.canvas.height);m.isDragging=false}}function a(m,j,g,o,k){if(k.plugins.dragable.dragCanvas.isDragging){var p=k.plugins.dragable.dragCanvas;var q=p._ctx;q.clearRect(0,0,q.canvas.width,q.canvas.height);p.isDragging=false;var h=p._neighbor;var r=k.series[h.seriesIndex];var i=r.plugins.dragable;var n=(i.constrainTo=="y")?h.data[0]:g[r.xaxis];var l=(i.constrainTo=="x")?h.data[1]:g[r.yaxis];r.data[h.pointIndex][0]=n;r.data[h.pointIndex][1]=l;k.drawSeries({preventJqPlotSeriesDrawTrigger:true},h.seriesIndex);p._neighbor=null;m.target.style.cursor=p._cursors.pop();k.target.trigger("jqplotDragStop",[j,g])}}})(jQuery); -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/plugins/jqplot.json2.min.js: -------------------------------------------------------------------------------- 1 | /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com 2 | jsDate | (c) 2010-2013 Chris Leonello 3 | */(function($){$.jqplot.JSON=window.JSON;if(!window.JSON){$.jqplot.JSON={}}function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;ib.max||b.max==null){b.max=f[c][1]}}}else{for(var c=0;cb.max||b.max==null){b.max=f[c][2]}}}};a.jqplot.OHLCRenderer.prototype.draw=function(A,N,j){var J=this.data;var v=this._xaxis.min;var z=this._xaxis.max;var l=0;var K=J.length;var p=this._xaxis.series_u2p;var G=this._yaxis.series_u2p;var D,E,f,M,F,n,O,C;var y;var u=this.renderer;var s=(j!=undefined)?j:{};var k=(s.shadow!=undefined)?s.shadow:this.shadow;var B=(s.fill!=undefined)?s.fill:this.fill;var c=(s.fillAndStroke!=undefined)?s.fillAndStroke:this.fillAndStroke;u.bodyWidth=(s.bodyWidth!=undefined)?s.bodyWidth:u.bodyWidth;u.tickLength=(s.tickLength!=undefined)?s.tickLength:u.tickLength;A.save();if(this.show){var m,q,g,Q,t;for(var D=0;Dq){if(u.wickColor){y.color=u.wickColor}else{if(u.downBodyColor){y.color=u.downBodyColor}}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,[[m,g],[m,q]],f);u.shapeRenderer.draw(A,[[m,t],[m,Q]],f);y={};M=q;F=t-q;if(u.fillDownBody){y.fillRect=true}else{y.strokeRect=true;n=n-this.lineWidth;O=m-n/2}if(u.downBodyColor){y.color=u.downBodyColor;y.fillStyle=u.downBodyColor}C=[O,M,n,F]}else{if(u.wickColor){y.color=u.wickColor}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,[[m,g],[m,Q]],f);y={};y.fillRect=false;y.strokeRect=false;O=[m-n/2,q];M=[m+n/2,t];n=null;F=null;C=[O,M]}}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,C,f)}else{E=s.color;if(u.openColor){s.color=u.openColor}if(!u.hlc){u.shapeRenderer.draw(A,[[m-u._tickLength,q],[m,q]],s)}s.color=E;if(u.wickColor){s.color=u.wickColor}u.shapeRenderer.draw(A,[[m,g],[m,Q]],s);s.color=E;if(u.closeColor){s.color=u.closeColor}u.shapeRenderer.draw(A,[[m,t],[m+u._tickLength,t]],s);s.color=E}}}A.restore()};a.jqplot.OHLCRenderer.prototype.drawShadow=function(b,d,c){};a.jqplot.OHLCRenderer.checkOptions=function(d,c,b){if(!b.highlighter){b.highlighter={showMarker:false,tooltipAxes:"y",yvalues:4,formatString:'
date:%s
open:%s
hi:%s
low:%s
close:%s
'}}}})(jQuery); -------------------------------------------------------------------------------- /HealthMetrics.WebService/Scripts/jqPlot/plugins/jqplot.trendline.min.js: -------------------------------------------------------------------------------- 1 | /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com 2 | jsDate | (c) 2010-2013 Chris Leonello 3 | */(function(f){f.jqplot.Trendline=function(){this.show=f.jqplot.config.enablePlugins;this.color="#666666";this.renderer=new f.jqplot.LineRenderer();this.rendererOptions={marker:{show:false}};this.label="";this.type="linear";this.shadow=true;this.markerRenderer={show:false};this.lineWidth=1.5;this.shadowAngle=45;this.shadowOffset=1;this.shadowAlpha=0.07;this.shadowDepth=3;this.isTrendline=true};f.jqplot.postSeriesInitHooks.push(e);f.jqplot.postDrawSeriesHooks.push(g);f.jqplot.addLegendRowHooks.push(a);function a(k){var j=null;if(k.trendline&&k.trendline.show){var i=k.trendline.label.toString();if(i){j={label:i,color:k.trendline.color}}}return j}function e(m,k,j,i,l){if(this._type&&(this._type==="line"||this._type=="bar")){this.trendline=new f.jqplot.Trendline();i=i||{};f.extend(true,this.trendline,{color:this.color},j.trendline,i.trendline);this.trendline.renderer.init.call(this.trendline,null)}}function g(m,i){i=f.extend(true,{},this.trendline,i);if(this.trendline&&i.show){var k;var l=i.data||this.data;k=c(l,this.trendline.type);var j=i.gridData||this.renderer.makeGridData.call(this,k.data);this.trendline.renderer.draw.call(this.trendline,m,j,{showLine:true,shadow:this.trendline.shadow})}}function b(w,v,n){var u=(n==null)?"linear":n;var s=w.length;var t;var z;var o=0;var m=0;var r=0;var q=0;var l=0;var j=[];var k=[];if(u=="linear"){k=w;j=v}else{if(u=="exp"||u=="exponential"){for(var p=0;p CreateServiceInstanceListeners() 23 | { 24 | return new[] 25 | { 26 | new ServiceInstanceListener( 27 | (parameters) => 28 | new HttpCommunicationListener("", new Startup(this.Context), parameters)) 29 | }; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /HealthMetrics.WebService/ServiceHost.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.WebService 7 | { 8 | using System; 9 | using System.Diagnostics; 10 | using System.Net; 11 | using System.Threading; 12 | using Microsoft.ServiceFabric.Services.Runtime; 13 | 14 | public static class ServiceHost 15 | { 16 | public static void Main(string[] args) 17 | { 18 | try 19 | { 20 | ServicePointManager.DefaultConnectionLimit = 10240; 21 | 22 | ServiceRuntime.RegisterServiceAsync(Service.ServiceTypeName, context => new Service(context)).GetAwaiter().GetResult(); 23 | 24 | ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, Service.ServiceTypeName); 25 | 26 | Thread.Sleep(Timeout.Infinite); 27 | } 28 | catch (Exception e) 29 | { 30 | ServiceEventSource.Current.ServiceHostInitializationFailed(e); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /HealthMetrics.WebService/Startup.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------ 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. 4 | // ------------------------------------------------------------ 5 | 6 | namespace HealthMetrics.WebService 7 | { 8 | using System; 9 | using System.Diagnostics; 10 | using System.Fabric; 11 | using System.Web.Http; 12 | using Microsoft.Owin; 13 | using Microsoft.Owin.FileSystems; 14 | using Microsoft.Owin.StaticFiles; 15 | using Owin; 16 | using Web.Service; 17 | 18 | public class Startup : IOwinAppBuilder 19 | { 20 | private readonly ServiceContext serviceContext; 21 | 22 | public Startup(ServiceContext serviceContext) 23 | { 24 | this.serviceContext = serviceContext; 25 | } 26 | 27 | public void Configuration(IAppBuilder appBuilder) 28 | { 29 | HttpConfiguration config = new HttpConfiguration(); 30 | 31 | config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; 32 | config.MapHttpAttributeRoutes(); 33 | FormatterConfig.ConfigureFormatters(config.Formatters); 34 | UnityConfig.RegisterComponents(config, this.serviceContext); 35 | 36 | try 37 | { 38 | appBuilder.UseWebApi(config); 39 | appBuilder.UseFileServer( 40 | new FileServerOptions() 41 | { 42 | EnableDefaultFiles = true, 43 | RequestPath = PathString.Empty, 44 | FileSystem = new PhysicalFileSystem(@".\wwwroot"), 45 | }); 46 | 47 | appBuilder.UseDefaultFiles( 48 | new DefaultFilesOptions() 49 | { 50 | DefaultFileNames = new[] {"healthmetrics/index.html"} 51 | }); 52 | 53 | appBuilder.UseStaticFiles( 54 | new StaticFileOptions() 55 | { 56 | FileSystem = new PhysicalFileSystem(@".\wwwroot\Content"), 57 | RequestPath = PathString.FromUriComponent(@"/Content"), 58 | ServeUnknownFileTypes = true 59 | }); 60 | 61 | config.EnsureInitialized(); 62 | } 63 | catch (Exception e) 64 | { 65 | Trace.WriteLine(e); 66 | } 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /HealthMetrics.WebService/packages.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 | -------------------------------------------------------------------------------- /HealthMetrics.WebService/wwwroot/Scripts/api.js: -------------------------------------------------------------------------------- 1 | function Api() { 2 | this.serviceUrl = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : ''); 3 | 4 | this.GetNationalStats = function (result) { 5 | this.httpGetJson(this.serviceUrl + '/api/national/stats', result); 6 | }; 7 | 8 | this.GetNationalHealth = function (result) { 9 | this.httpGetJson(this.serviceUrl + '/api/national/health', result); 10 | }; 11 | 12 | this.GetCountyHealth = function (countyId, result) { 13 | this.httpGetJson(this.serviceUrl + '/api/county/' + countyId + '/health', result); 14 | }; 15 | 16 | this.GetDoctors = function (countyId, result) { 17 | this.httpGetJson('/api/county/' + countyId + '/doctors', result); 18 | }; 19 | 20 | this.GetPatient = function (bandId, result) { 21 | this.httpGetJson(this.serviceUrl + '/api/patients/' + bandId, result); 22 | }; 23 | 24 | this.GetSetting = function (settingName, result) { 25 | this.httpGetJson(this.serviceUrl + '/api/settings/' + settingName, result); 26 | }; 27 | 28 | this.GetIds = function (result) { 29 | this.httpGetJson(this.serviceUrl + '/api/settings/GetIds', result); 30 | }; 31 | 32 | this.httpGetJson = function (url, result) { 33 | $.ajax({ 34 | url: url, 35 | type: 'GET', 36 | contentType: 'application/json', 37 | datatype: 'json', 38 | cache: false 39 | }) 40 | .done(function (data) { 41 | result(data); 42 | }) 43 | .fail(function () { 44 | return; 45 | }); 46 | } 47 | } -------------------------------------------------------------------------------- /HealthMetricsApplication/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 |
79 |
80 |
-------------------------------------------------------------------------------- /HealthMetricsApplication/ApplicationParameters/Cloud.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /HealthMetricsApplication/ApplicationParameters/Local.1Node.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /HealthMetricsApplication/ApplicationParameters/Local.5Node.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /HealthMetricsApplication/ApplicationParameters/Local.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /HealthMetricsApplication/HealthMetrics.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /HealthMetricsApplication/HealthMetrics.sfproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 165c0d41-afb4-49d1-a60a-5a35a22d5951 6 | 1.6 7 | v4.5.2 8 | 1.5 9 | 10 | 11 | 12 | Debug 13 | x64 14 | 15 | 16 | Release 17 | x64 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 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /HealthMetricsApplication/PublishProfiles/Cloud.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HealthMetricsApplication/PublishProfiles/Local.1Node.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /HealthMetricsApplication/PublishProfiles/Local.5Node.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /HealthMetricsApplication/PublishProfiles/Local.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /HealthMetricsApplication/Scripts/ApplicationPackageUpgrade.ps1: -------------------------------------------------------------------------------- 1 | $cloud = $false 2 | 3 | if($cloud) 4 | { 5 | $imageStoreConnectionString = "fabric:ImageStore" 6 | } 7 | else 8 | { 9 | $imageStoreConnectionString = "file:C:\SfDevCluster\Data\ImageStoreShare" 10 | } 11 | 12 | $scriptPath = Get-Item(Convert-Path($MyInvocation.MyCommand.Path)) 13 | $scriptDirectory = Get-Item(Convert-Path($scriptPath.PSParentPath)) 14 | 15 | $upgradePackagePath = "$scriptDirectory\HealthMetricsV2ConfigOnlyPackage" 16 | 17 | Test-ServiceFabricApplicationPackage -ApplicationPackagePath $upgradePackagePath -ImageStoreConnectionString $imageStoreConnectionString 18 | Copy-ServiceFabricApplicationPackage -ApplicationPackagePath $upgradePackagePath -ImageStoreConnectionString $imageStoreConnectionString -ApplicationPackagePathInImageStore "HealthMetricsV2" 19 | Register-ServiceFabricApplicationType -ApplicationPathInImageStore "HealthMetricsV2" 20 | 21 | Start-ServiceFabricApplicationUpgrade -ApplicationName "fabric:/HealthMetrics" -ApplicationTypeVersion "2.0.0.0" -Monitored -FailureAction Rollback -Force 22 | -------------------------------------------------------------------------------- /HealthMetricsApplication/Scripts/HealthMetricsCleanup.ps1: -------------------------------------------------------------------------------- 1 | $cloud = $false 2 | $secure = $false 3 | 4 | if($cloud) 5 | { 6 | $cloudAddress = "" 7 | $clusterAddress = $cloudAddress+":19000" 8 | } 9 | else 10 | { 11 | $clusterAddress = "127.0.0.1:19000" 12 | } 13 | 14 | if($secure) 15 | { 16 | $thumbprint = "" 17 | $commonName = "" 18 | } 19 | 20 | if($secure) 21 | { 22 | Connect-ServiceFabricCluster $clusterAddress -FindType FindByThumbprint -FindValue $thumbprint -X509Credential -ServerCertThumbprint $thumbprint -ServerCommonName $commonName -StoreLocation CurrentUser -StoreName My -Verbose 23 | } 24 | else 25 | { 26 | Connect-ServiceFabricCluster -ConnectionEndpoint $clusterAddress 27 | } 28 | 29 | Get-ServiceFabricApplication -ApplicationName "fabric:/HealthMetrics" | Remove-ServiceFabricApplication -Force -ForceRemove 30 | Get-ServiceFabricApplicationType -ApplicationTypeName "HealthMetrics" | Unregister-ServiceFabricApplicationType -Force 31 | 32 | $folders = Get-ServiceFabricImageStoreContent -ImageStoreConnectionString $imageStoreConnectionString 33 | 34 | if($folders -ne "Invalid location or unable to retrieve image store content") 35 | { 36 | foreach($folder in $folders) 37 | { 38 | if(($folder.StoreRelativePath -ne "Store") -and ($folder.StoreRelativePath -ne "WindowsFabricStore")) 39 | { 40 | Remove-ServiceFabricApplicationPackage -ApplicationPackagePathInImageStore $folder.StoreRelativePath -ImageStoreConnectionString $imageStoreConnectionString 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /HealthMetricsApplication/Scripts/HealthMetricsConfigParamUpgrade.ps1: -------------------------------------------------------------------------------- 1 | $cloud = $false 2 | $secure = $false 3 | 4 | if($cloud) 5 | { 6 | $cloudAddress = "" 7 | $clusterAddress = $cloudAddress+":19000" 8 | } 9 | else 10 | { 11 | $clusterAddress = "127.0.0.1:19000" 12 | } 13 | 14 | if($secure) 15 | { 16 | $thumbprint = "" 17 | $commonName = "" 18 | } 19 | 20 | if($secure) 21 | { 22 | Connect-ServiceFabricCluster $clusterAddress -FindType FindByThumbprint -FindValue $thumbprint -X509Credential -ServerCertThumbprint $thumbprint -ServerCommonName $commonName -StoreLocation CurrentUser -StoreName My -Verbose 23 | } 24 | else 25 | { 26 | Connect-ServiceFabricCluster -ConnectionEndpoint $clusterAddress 27 | } 28 | 29 | $parameters = @{} 30 | $parameters.Add("ScoreCalculationMode","Mode2") 31 | $parameters.Add("GenerateKnownPeople","false") 32 | Start-ServiceFabricApplicationUpgrade -ApplicationName "fabric:/HealthMetrics" -ApplicationTypeVersion "1.0.0.0" -Monitored -FailureAction Rollback -ApplicationParameter $parameters -Force -UpgradeReplicaSetCheckTimeoutSec 60 -HealthCheckRetryTimeoutSec 1 -HealthCheckWaitDurationSec 1 -HealthCheckStableDurationSec 1 -UpgradeDomainTimeoutSec 180 -UpgradeTimeoutSec 900 33 | #Send-ServiceFabricServiceHealthReport -HealthProperty SomeHealthReport -HealthState Error -ServiceName fabric:/HealthMetrics/HealthMetrics.NationalService -SourceId user -RemoveWhenExpired -TimeToLiveSec 240 34 | 35 | while($true) 36 | { 37 | $upgradeResults = Get-ServiceFabricApplicationUpgrade -ApplicationName "fabric:/HealthMetrics" 38 | $upgradeResults 39 | sleep 5 40 | 41 | if(($upgradeResults.UpgradeState -eq "RollingForwardCompleted") -or ($upgradeResults.UpgradeState -eq "RollingBackCompleted")) 42 | { 43 | break 44 | } 45 | } -------------------------------------------------------------------------------- /HealthMetricsApplication/Scripts/HealthMetricsV2ConfigOnlyPackage/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 |
79 |
80 |
-------------------------------------------------------------------------------- /HealthMetricsApplication/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /HealthMetricsApplication/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. --------------------------------------------------------------------------------