/// <summary> /// Sends statistics to the SDN server but only if there are more than 100 person records /// or the sample data has not been loaded. /// /// The statistics are: /// * Rock Instance Id /// * Update Version /// * IP Address - The IP address of your Rock server. /// /// ...and we only send these if they checked the "Include Impact Statistics": /// * Organization Name and Address /// * Public Web Address /// * Number of Active Records /// /// As per https://www.rockrms.com/Rock/Impact /// </summary> /// <param name="version">the semantic version number</param> private void SendStatictics(string version) { try { var rockContext = new RockContext(); int numberOfActiveRecords = new PersonService(rockContext).Queryable(includeDeceased: false, includeBusinesses: false).Count(); if (numberOfActiveRecords > 100 || !Rock.Web.SystemSettings.GetValue(Rock.SystemKey.SystemSetting.SAMPLEDATA_DATE).AsDateTime().HasValue) { string organizationName = string.Empty; ImpactLocation organizationLocation = null; string publicUrl = string.Empty; var rockInstanceId = Rock.Web.SystemSettings.GetRockInstanceId(); var ipAddress = Request.ServerVariables["LOCAL_ADDR"]; if (cbIncludeStats.Checked) { var globalAttributes = GlobalAttributesCache.Get(); organizationName = globalAttributes.GetValue("OrganizationName"); publicUrl = globalAttributes.GetValue("PublicApplicationRoot"); // Fetch the organization address var organizationAddressLocationGuid = globalAttributes.GetValue("OrganizationAddress").AsGuid(); if (!organizationAddressLocationGuid.Equals(Guid.Empty)) { var location = new Rock.Model.LocationService(rockContext).Get(organizationAddressLocationGuid); if (location != null) { organizationLocation = new ImpactLocation(location); } } } else { numberOfActiveRecords = 0; } var environmentData = RockUpdateHelper.GetEnvDataAsJson(Request, ResolveRockUrl("~/")); // now send them to SDN/Rock server SendToSpark(rockInstanceId, version, ipAddress, publicUrl, organizationName, organizationLocation, numberOfActiveRecords, environmentData); } } catch (Exception ex) { // Just catch any exceptions, log it, and keep moving... We don't want to mess up the experience // over a few statistics/metrics. try { LogException(ex); } catch { } } }
/// <summary> /// Checks the .NET Framework version and returns Pass, Fail, or Unknown which can be /// used to determine if it's safe to proceed. /// </summary> /// <returns>One of the values of the VersionCheckResult enum.</returns> private DotNetVersionCheckResult CheckFrameworkVersion() { var result = DotNetVersionCheckResult.Fail; try { // Once we get to 4.5 Microsoft recommends we test via the Registry... result = RockUpdateHelper.CheckDotNetVersionFromRegistry(); } catch { // This would be pretty bad, but regardless we'll return // the Unknown result and let the caller proceed with caution. result = DotNetVersionCheckResult.Unknown; } return(result); }
/// <summary> /// Sends statistics to the SDN server but only if there are more than 100 person records /// or the sample data has not been loaded. /// /// The statistics are: /// * Rock Instance Id /// * Update Version /// * IP Address - The IP address of your Rock server. /// /// ...and we only send these if they checked the "Include Impact Statistics": /// * Organization Name and Address /// * Public Web Address /// * Number of Active Records /// /// As per http://www.rockrms.com/Rock/Impact /// </summary> /// <param name="version">the semantic version number</param> private void SendStatictics(string version) { try { var ipAddress = Request.ServerVariables["LOCAL_ADDR"]; var environmentData = RockUpdateHelper.GetEnvDataAsJson(Request, ResolveRockUrl("~/")); using (var rockContext = new RockContext()) { var instanceStatistics = new RockInstanceImpactStatistics(new RockImpactService(), rockContext); instanceStatistics.SendImpactStatisticsToSpark(cbIncludeStats.Checked, version, ipAddress, environmentData); } } catch (Exception ex) { // Just catch any exceptions, log it, and keep moving... We don't want to mess up the experience // over a few statistics/metrics. try { LogException(ex); } catch { } } }