Skip to content

Instantly share code, notes, and snippets.

/**
* Used to read a delimited file.
*/
public class SSSCsvReader {
private String delim = ',';
// the input data
private String[] buffer;
public SSSCsvReader(String data){
this.buffer = data.split('\n');
@isTest
private class SSSCsvReaderTest {
static testmethod void testSplitCsvSimple(){
String line = 'abc,efg';
String[] splitted = new SSSCsvReader(line).readLine();
System.assertEquals(2, splitted.size());
System.assertEquals('efg', splitted[1]);
System.assertEquals('abc', splitted[0]);
}
using System;
using System.Collections.Generic;
using System.Text;
using Sage.Platform.Application;
using Sage.Platform.Application.UI;
using Sage.Platform.Security;
using Sage.SalesLogix.Web;
using Sage.SalesLogix.Security;
using System.Reflection;
using Sage.Entity.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using Sage.Integration.Web;
using Sage.Platform.Application;
using Sage.Integration.Messaging.Model;
namespace SSSWorld.RFI.BusinessRules.CustomerPortalSecurity
@f1code
f1code / DateTimeParser.cs
Created September 8, 2015 21:49
DateTimeParser with Timezone string conversion
public static class DateTimeParser
{
private static readonly Dictionary<string, string> TimeZones = new Dictionary<string, string>()
{
{"CDT", "-0500"},
{"CST", "-0600"},
{"EDT", "-0400"},
{"EST", "-0500"},
{"PDT", "-0700"},
{"PST", "-0800"},
@f1code
f1code / README.markdown
Last active September 9, 2015 09:38 — forked from beccasaurus/README.markdown
Adds hooks to jQuery.validate's form/element validation methods (via trigger())

jQuery Validate Hooks

If you're using [ASP.NET MVC3][], it uses [jQuery Validate][] to do client-side validations. Instead of using [jQuery Validate][] directly, however, it wraps it with its own jQuery plugin called [jQuery.Validate.Unobtrusive][]. [jQuery.Validate.Unobtrusive][] sets up [jQuery Validate][] for you, behind the scenes, so you don't have an opportunity to customize your [jQuery Validate][] settings at all!

We've been running into trouble with this when we've been doing our own custom client-side validations. We need a way to integrate with the build-in [ASP.NET MVC3][] validation so we can:

@f1code
f1code / CustomDashboardPageSetting.js
Last active May 8, 2017 21:25
Javascript Snippets for Infor CRM
define(['Sage/UI/Dashboard/DashboardPage', 'dojo/aspect', 'dojo/query', 'dojo/dom-construct', './MultiSelectDropdown', './PicklistDataStore'],
function (DashboardPage, aspect, query, domConstruct, MultiSelect, PicklistDataStore) {
var _portalAccess = undefined;
aspect.after(DashboardPage.prototype, '_editOptionsMenu', function () {
var trButtons = query('.dijitDialog .edit-options-table > table > tbody > tr');
if (trButtons.length == 0) {
console.warn('Unable to find options dialog');
return;
}
@f1code
f1code / IsDateAfterAttribute.cs
Last active October 11, 2016 10:36
ASP.NET MVC ValidationAttribute ensuring one date is greater than another
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace WebUI.Infrastructure
{
/// <summary>
/// Validation attribute ensuring a date property is greater than another one specified.
/// </summary>
@f1code
f1code / MultiSelectDropdown.css
Created September 24, 2015 16:50
A multi select dropdown for dojo.
div.multiselect
{
background-color: White;
border: 1px solid #A8A9BE;
text-align: left;
height: 180px;
z-index: 999;
padding: 2px;
}
div.multiselect div.checkboxList
// With Count
var count = sess.QueryOver<ITicket>()
.Where(x => (x.SentBundle == false || x.SentBundle == null)
&& x.ScheduledDate >= startDate && x.ScheduledDate <= endDate &&
(string)x.Contact.Id == (string)contact.Id)
.Select(Projections.Count("Id"))
.SingleOrDefault<int>();