Skip to content

Instantly share code, notes, and snippets.

View KevM's full-sized avatar

Kevin Miller KevM

View GitHub Profile
@KevM
KevM / a_viewmodel.cs
Created January 24, 2012 20:28
Bootstrap FubuMVC HtmlConvention
public class CreateCaseModel : IApi
{
public bool UserIsAuthenticated { get; set; }
public string ContactFirstName { get; set; }
public string ContactLastName { get; set; }
public string ContactPhone { get; set; }
public string SiteId { get; set; }
public string Queue { get; set; }
public string Title { get; set; }
@KevM
KevM / a_readme.md
Created January 30, 2012 17:11
Example rake file for applying schema scripts and running sql

Dovetail Automation

Running the rake script below will

  1. Apply all schema scripts ending in .schemascript.xml found in the child schema directory.
  2. Execute all .sql scripts found in the child database directory.

Setup

  1. Edit the rakefile.rb to have your correct database configuration.
@KevM
KevM / Cache.cs
Created February 8, 2012 16:39
Caching in .Net
public interface ICache<T>
{
T Get(string key);
void Set(string key, T value);
Func<string, T> OnMissing { set; }
TimeSpan CacheTimeSpan { get; set; }
}
public class AspNetCache<T> : ICache<T> where T : class
@KevM
KevM / usersloggingintoday.cs
Created February 29, 2012 17:04
New School Dovetail SDK access with some extension help
public class User
{
public int ID { get; set; }
public string Login { get; set; }
}
public IEnumerable<User> UsersLoggingInToday(string username)
{
var dataSet = _session.CreateDataSet();
var userGeneric = dataSet.CreateGenericWithFields("user", "login_name");
public IEnumerable<User> UsersLoggingInTodayOld(string username)
{
var dataSet = _session.CreateDataSet();
var userGeneric = dataSet.CreateGeneric("user");
userGeneric.DataFields.Add("login_name");
userGeneric.AppendFilter("login_name", StringOps.Equals, username);
userGeneric.AppendFilter("last_login", DateOps.After, DateTime.Now.AddDays(-1));
userGeneric.Query();
var results = new List<User>();
public static class ClarifyGenericExtensions
{
public static ClarifyGeneric Filter(this ClarifyGeneric generic, Func<FilterExpression, Filter> filterFunction)
{
var filterExpression = new FilterExpression();
var filter = filterFunction(filterExpression);
generic.Filter.AddFilter(filter);
public static class ClarifyDataRowExtensions
{
public static int DatabaseIdentifier(this ClarifyDataRow row)
{
return Convert.ToInt32(row.UniqueID);
}
public static string AsString(this ClarifyDataRow row, string fieldName)
{
return row[fieldName] == DBNull.Value ? null : row[fieldName].ToString();
@KevM
KevM / gist:2002680
Created March 8, 2012 18:52
Ripple local
c:\projects\bootstrap>buildsupport\ripple.exe local -from Dovetail.SDK -to bootstrap
The root code directory for ripple is c:\projects
ripple.exe is at c:\projects\bootstrap\buildsupport\ripple.exe
Trying to read a Ripple SolutionGraph from c:\projects
ERROR: System.ArgumentException: The key 'fubumvc' already exists. ---> System.ArgumentException: An item with the same
key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
@KevM
KevM / FubuRegistryExtensions.cs
Created March 12, 2012 18:09
FubuRegistry Extensions
public static class FubuRegistryExtensions
{
public static void UseExtension<T>(this FubuRegistry fubuRegistry)
{
fubuRegistry.UseExtension<T>(s => { });
}
public static void UseExtension<T>(this FubuRegistry fubuRegistry, Action<T> configure) where T : class, new()
{
var extension = new T();
@KevM
KevM / web_service_example.cs
Created March 16, 2012 21:39
CSharp test fixture that creates a case using a webservice based on the Dovetail SDK
using System;
using System.Collections.Specialized;
using System.Net;
using System.Web.Script.Serialization;
using NUnit.Framework;
namespace Micros.Clarify.Webservices.Tests
{
public class CreateCaseResult
{