Skip to content

Instantly share code, notes, and snippets.

public long Count()
{
var woCount = _unitOfWork.CurrentSession
.CreateQuery("select count(*) from Workorder")
.UniqueResult<long>();
return woCount;
}
public Preference GetDefaultValuePreference(int domain, string name)
{
if (domain < 0) throw new ArgumentOutOfRangeException(Resources.InvalidDomainMustBeZeroOrGreater);
if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name");
var preference = _unitOfWork.CurrentSession.Get<Preference>(new Preference { DomainId = domain, ElementId = name });
return preference ?? new Preference { DefaultValue = string.Empty, DomainId = domain, ElementId = name };
}
/// <summary>
/// All of the dependencies for the core Cityworks processing
/// </summary>
public class CityworksCoreRegistry : Registry
{
public CityworksCoreRegistry()
{
ForRequestedType<ILogFactory>().TheDefaultIsConcreteType<NLogFactory>();
ISessionFactory cityworks = NHibernateHelper.SessionFactory(Resources.CityworksDatasource);
@ECHO OFF
cd tools
if not exist ironruby\nul 7zip\7za.exe x -y ironruby.7z
cd ..
set PATH=%PATH%;C:\Windows\Microsoft.NET\Framework\v3.5;%CD%\tools\ironruby\bin
set GEM_PATH=%CD%\tools\ironruby\lib\ruby\gems\1.8
set GEM_HOME=%CD%\tools\ironruby\lib\ruby\gems\1.8
$LOAD_PATH << './source/Tasks/'
# Command configuration items - if this changes it should change
# for all users
APP_SETTINGS = YAML.load_file('common.yml')
# Create user settings if not present
setting_template = "config.yml.template"
if !File.exist?(setting_template.ext(''))
p setting_template.ext('')
development:
database:
city: 'Data Source=DWHS;User ID=yahooozi;Password=look-the-other-way;'
eventservices: you-get-the-idea
security: this-is-where-setting-values-go
servers:
gisserver: someservername
webserver: yepanothername
production:
database:
@dvhthomas
dvhthomas / build.rb
Created November 5, 2009 05:52
Sample rake tasks
require 'rexml/document'
@json_files
@xml_files
# This set of tasks assumes that some settings have been already
# been loaded in to globals called APP_SETTINGS and USER_SETTINGS.
# Pretty much everything will fail until that has been done, usually
# in a calling rakefile
desc "Default build task"
@dvhthomas
dvhthomas / heartbeat.cs
Created November 14, 2009 03:12
Circuit breaker usage
using System;
using System.Collections.Generic;
using CityIQ.HealthMonitor.Notifiers;
using CityIQ.HealthMonitor.Testers;
namespace CityIQ.HealthMonitor
{
/// <summary>
/// Implementation that can make requests of services and optionally notify
/// interested parties of the results.
@dvhthomas
dvhthomas / heartbeatregistry.cs
Created November 14, 2009 03:15
Heartbeat monitor IoC registry
using System;
using System.Configuration;
using CityIQ.HealthMonitor.Notifiers;
using CityIQ.HealthMonitor.Testers;
using StructureMap.Attributes;
using StructureMap.Configuration.DSL;
namespace CityIQ.HealthMonitor
{
public class HeartbeatRegistry : Registry
@dvhthomas
dvhthomas / circuitbreaker.cs
Created November 14, 2009 03:16
Circuit Breaker implementation
using System;
using System.Timers;
namespace CityIQ.HealthMonitor
{
/// <summary>
/// Intercepts calls to brittle or problematic resources
/// and maintains state of the resource using a circuit breaker
/// analogy. A closed circuit is good, and open circuit is bad because
/// it means that the resource being called is not responding within