Skip to content

Instantly share code, notes, and snippets.

@proteux
proteux / ugly.cs
Last active December 17, 2015 17:38
RightNow Custom Field via SOAP
Contact contact = new Contact
{
CustomFields = new GenericObject
{
GenericFields = new GenericField[]
{
new GenericField
{
name = "c",
dataType = DataTypeEnum.OBJECT,
/// <summary>
/// show the form as a toast notification
/// </summary>
/// <param name="parent">the parent form, we'll use this as a position guide</param>
/// <param name="xOffset">amount to offset in the X direction</param>
/// <param name="yOffset">amount to offset in the Y direction</param>
public void Toast(Form parent, int xOffset = 6, int yOffset = 6)
{
this.Show();
@proteux
proteux / dnb2.cs
Last active December 15, 2015 17:29
Using DotNetBar1 Themes in DotNetBar2
extern alias dnb2;
//other usings
using DevComponents.DotNetBar.Rendering;
using DevComponents.DotNetBar;
namespace DNB2Sample
{
class WorkspaceControl_DotNetBar : UserControl
{
@proteux
proteux / assignAgent.cs
Created March 4, 2013 19:55
Assigns the current incident to the current user
/// <summary>
/// 'assign to me' button has been clicked. set the assigned field to the current account
/// </summary>
private void button_assign_Click(object sender, EventArgs e)
{
if (incidentRecord != null)
{
incidentRecord.Assigned.AcctID = globalContext.AccountId;
}
}
@proteux
proteux / LoadIncidentData.cs
Created March 4, 2013 19:51
Load an incident record
/// <summary>
/// the workspace has finished loading the data, get a reference to the incident data
/// </summary>
internal void LoadData()
{
//check that we're on the correct type of workspace
if (recordContext.WorkspaceType == WorkspaceRecordType.Incident)
{
//grab the incident
incidentRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Incident) as IIncident;
@proteux
proteux / AsyncAcctLoad.cs
Created March 3, 2013 04:39
Load account async
/// <summary>
/// the workspace has finished loading. load the account from CWS
/// </summary>
internal void LoadData()
{
//make sure we connected successfully
if (RightNowSoapClient.Instance.IsConnected)
{
//get the account from CWS
RightNowSoapClient.Instance.client.GetAsync(
@proteux
proteux / Factory.cs
Created March 3, 2013 00:32
inits the RNT CWS connection using the add-in context
/// <summary>
/// init the add-in and connect to the SOAP API
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public bool Initialize(IGlobalContext context)
{
globalContext = context;
//it would be nice to be able to check context.CanAccessPublicSoap
@proteux
proteux / LazySingleton.cs
Created March 3, 2013 00:27
Creating a Lazy<> singleton
#region singleton
/// <summary>
/// singleton initializer using the Lazy<<> class
/// </summary>
private static readonly Lazy<RightNowSoapClient> _instance = new Lazy<RightNowSoapClient>(() => new RightNowSoapClient());
/// <summary>
/// singleton access
/// </summary>
public static RightNowSoapClient Instance { get { return _instance.Value; } }
/// <summary>
/// create the connection based on the global context
/// </summary>
/// <param name="context">global context of the site you're connecting to</param>
internal void Init(IGlobalContext context)
{
try
{
//get the end point address from the global context
EndpointAddress endPointAddr = new EndpointAddress(context.GetInterfaceServiceUrl(ConnectServiceType.Soap));
@proteux
proteux / WorkspaceControl.cs
Last active December 12, 2015 03:08
RNT AddIn - Overloaded WorkspaceControl Constructor
/// <summary>
/// AddIn constructor: stores the design mode flag
/// and lets the standard constructor create the UI
/// </summary>
/// <param name="inDesignMode">true if we're on a workspace designer</param>
public WorkspaceControl(bool inDesignMode) : this()
{
this.inDesignMode = inDesignMode;
}