Skip to content

Instantly share code, notes, and snippets.

View janvanderhaegen's full-sized avatar

Jan Van der Haegen janvanderhaegen

View GitHub Profile
@janvanderhaegen
janvanderhaegen / LoadOnDemandExtensions.cs
Last active January 19, 2020 05:42
Loading of collections in the desktop client on a 'need to see' basis.
using Microsoft.LightSwitch.Client;
using Microsoft.LightSwitch.Details.Client;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using Microsoft.LightSwitch.Presentation.Internal;
using Microsoft.LightSwitch.Sdk.Proxy;
using Microsoft.VisualStudio.ExtensibilityHosting;
using System;
using System.Collections.Generic;
@janvanderhaegen
janvanderhaegen / myscreen.lsml.js
Created October 7, 2014 00:57
SP Overlay: CSS
myapp.menuHome.buttonResources_postRender = function (element, contentItem) {
$(element).spOverlay(contentItem, 'Content/Images/TouchIcons/ResourcesLarge.png', { height:170, width:170});
};
myapp.menuHome.buttonDesigns_postRender = function (element, contentItem) {
$(element).spOverlay(contentItem, 'Content/Images/TouchIcons/DesignsLarge.png');
};
myapp.menuHome.buttonProjects_postRender = function (element, contentItem) {
$(element).spOverlay(contentItem, 'Content/Images/TouchIcons/ProjectsLarge.png');
@janvanderhaegen
janvanderhaegen / ExpressionCombiner
Created September 5, 2014 19:59
C# code to combine two lambda expressions
//Shoutout to MBoros on stackoverflow
public static class ExpressionCombiner {
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> exp, Expression<Func<T, bool>> newExp)
{
// get the visitor
var visitor = new ParameterUpdateVisitor(newExp.Parameters.First(), exp.Parameters.First());
// replace the parameter in the expression just created
newExp = visitor.Visit(newExp) as Expression<Func<T, bool>>;
// now you can and together the two expressions
var userViewer = $('<a id="userviewer" href="#" target="_self" >' + user.Name + '</a>');
userViewer.appendTo($(".msls-screen-buttons"));
//interaction 1
userViewer.on('click', function () {
myapp.showEditMyProfile(user);
});
contentItem.dataBind("value.Name", function () {
//interaction 2
$("#userviewer").text(contentItem.value.Name);
@janvanderhaegen
janvanderhaegen / ColorBackground
Created January 22, 2014 14:29
Colors the background of a control.
public static IEnumerable<IContentItemPresenter> GetAssociatedPresenters(this IContentItem contentItem)
{
var internale = contentItem as IContentItemInternal;
if (internale == null)
return new List<IContentItemPresenter>();
return internale.AssociatedPresenters;
}
public static void SetBackground(this IContentItemPresenter presenter, Color color)
@janvanderhaegen
janvanderhaegen / FindContentItems.cs
Created January 22, 2014 14:25
Finds contentitems for an IEntityProperty
public static List<IContentItem> FindContentItems(this IScreenObject screen, IEntityProperty viewModel)
{
IPresentationScreenView screenView = VsExportProviderService
.GetServiceFromCache<IServiceProxy>().ScreenViewService.GetScreenView(screen) as IPresentationScreenView;
if (screenView == null)
{
throw new InvalidOperationException();
}
IContentItem currentView = screenView.ContentItemTree;
@janvanderhaegen
janvanderhaegen / script.js
Last active May 2, 2018 20:34
Keep your site hot
function CheckMySite() {
//Thanks to Sandrino Di Mattia: http://fabriccontroller.net/blog/posts/job-scheduling-in-windows-azure/
warmUpSite("https://mysite.azurewebsites.net/HTMLClient/default.htm");
warmUpSite("https://mysecondsite.azurewebsites.net/HTMLClient/default.htm");
}
function warmUpSite(url) {
var currentdate = new Date();
<#@ template debug="true" hostSpecific="true" #>
<#@ output extension=".cs" #>
<#@ Assembly Name="System" #>
<#@ Assembly Name="System.Core.dll" #>
<#@ Assembly Name="System.Xml.dll" #>
<#@ Assembly Name="System.Xml.Linq.dll" #>
<#@ Assembly Name="System.Windows.Forms.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
@janvanderhaegen
janvanderhaegen / Script.SampleCustomers.sql
Created September 24, 2013 09:05
Inserts a couple of sample customers and orders
SET IDENTITY_INSERT [dbo].[Customers] ON;
MERGE INTO [dbo].[Customers] AS Target
USING (VALUES
(1, 'Beth Massi', 'F', 'Burg 1', '8000', 'Brugge', 'Belgium', 1.00),
(2, 'Chris Rummel', 'M', 'Burg 1', '8000', 'Brugge', 'Belgium', 0.90 ),
(3, 'Matt Evans', 'M', 'Burg 1', '8000', 'Brugge', 'Belgium', 0.80 ),
(4, 'Andy Kung', 'M', 'Burg 1', '8000', 'Brugge', 'Belgium', 0.70 ),
(5, 'Brian Moore', 'M', 'Burg 1', '8000', 'Brugge', 'Belgium', 0.60 ),
(6, 'Matt Sampson', 'F', 'Burg 1', '8000', 'Brugge', 'Belgium', 0.50 ),