Skip to content

Instantly share code, notes, and snippets.

@dudelis
dudelis / GetComputers.cs
Last active March 25, 2018 18:54
Get Computers from AD
public static class AdQueryHelper
{
public static List<AdObject> GetComputers(string ldapPath, int sizeLimit, int pageSize)
{
List<AdObject> adEntries = new List<AdObject>();
using (DirectoryEntry entry = new DirectoryEntry(ldapPath))
{
using (DirectorySearcher mySearcher = new DirectorySearcher(entry))
{
mySearcher.Filter = ("(objectClass=computer)");
@dudelis
dudelis / k2-checkbox.html
Last active March 25, 2018 18:54
K2: Checkbox html
<!-- Checked -->
<label class="input-control checkbox checked" data-defaultvalue="false">
<span class="input-control-img"></span>
</label>
<!-- Not checked -->
<label class="input-control checkbox" data-defaultvalue="false">
<span class="input-control-img"></span>
</label>
@dudelis
dudelis / Excel-GetCellValue.cs
Created February 26, 2018 13:52
Excel - Get cell value (OpenXML)
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
public static string GetCellValue(string fileName, string sheetName, string addressName)
{
string value = null;
using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileName, false))
{
WorkbookPart wbPart = document.WorkbookPart;
Sheet theSheet = wbPart.Workbook.Descendants<Sheet>().Where(s => s.Name == sheetName).FirstOrDefault();
@dudelis
dudelis / k2-listcolumn-highlight.html
Last active March 25, 2018 18:54
K2: Highlighting a column in a List View
<!--Insert the snippet below in a Literal Datalabel -->
<style type="text/css">
div[name="View Name"] .grid-body tbody td:nth-child(%ColumnNumber%) {
background: #FFFACD !important
}
</style>
@dudelis
dudelis / k2-ci-demo-package.ps1
Created February 28, 2018 11:08
K2 Automatic Build
param([string]$appName, [string]$categoryPath)
if(-not($appName)){ Throw "You must provide the name for your application"}
if(-not($categoryPath)){ Throw "You must provide the path for your application category"}
#01. Create a folder for the output
New-Item -ItemType Directory -Force -Path $PSScriptRoot\PND
#02. Create a package
Import-Module $PSScriptRoot\Assemblies\K2Field.Powershell.Module.dll -Verbose -Force
@dudelis
dudelis / k2-listbox-option-draggable.js
Created March 6, 2018 11:31
K2: Draggable listbox options
//Converting the 'text' into '{text}' for the Email Templating placeholders
var dragListBox = function(ev) {
ev.dataTransfer.setData("text",'{' + ev.srcElement.text + '}');
};
//Adding html attributes to make the inner items draggable
$('div[name="NameOfYourListBox"]')
.find('.optionwrapper')
.find('.option')
.attr('draggable', 'true')
.attr('ondragstart', 'dragListBox(event)');
@dudelis
dudelis / k2-ci-demo-deploy.ps1
Created March 12, 2018 14:53
K2 Automatic Deployment
#Adds the PowerShell Deployment snapin.
add-pssnapin SourceCode.Deployment.PowerShell
#Scripts the deployment of a package
Deploy-Package $(System.DefaultWorkingDirectory)/K2-CI-Demo-CI/$(Build.BuildNumber)/ExpenseClaim.kspx $(System.DefaultWorkingDirectory)/K2-CI-Demo-CI/$(Build.BuildNumber)/ExpenseClaim.xml
@dudelis
dudelis / k2-download-multiple-files-oneclick.js
Created May 4, 2018 10:20
How to download multiple files from List View in one click.
var files = $('[name="NameOfYourView"]').find('.grid-body').find('.fileImage.static');
function download_next(i) {
if (i >= files.length) {
return;
}
var sure = confirm('Are you sure you want to download the file ' + files[i].text +'?');
if (sure){
$(files[i]).click();
}
@dudelis
dudelis / k2-textarea-autogrow.html
Last active July 2, 2018 10:08
K2: Making TextArea autogrow
<script>
$(document).ready(function(){
const tAreaControlPath = "Controllers/Controller/Controls/Control[@Name='tareaObjectiveDescription']";
const tAreaControlXml = $sn($xml(__runtimeControllersDefinition), tAreaControlPath);
const tAreaContrId = tAreaControlXml.getAttribute('ID');
$('#' + tAreaContrId + '_TextArea').css('height', '5px');
const newHeight = $('#' + tAreaContrId + '_TextArea')[0].scrollHeight + 3 + "px";
$('#' + tAreaContrId + '_TextArea').css('height', newHeight);
});
</script>
@dudelis
dudelis / Users.csv
Last active July 6, 2018 12:28
Migrate K2 Users
oldlogin newlogin
DENALLIX\bob DENALLIX\joe
DENALLIX\Administrator DENALLIX\markus