Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
(**
DataManagement Helper
=====================
Libraries
---------
Config information *)
#load @"DG.Delegate.HowToDaxif.Config.fsx"
module cfg = DG.Delegate.HowToDaxif.Config
(** Open libraries for use *)
#r @"System.ServiceModel"
(** Open libraries for use *)
open System
open System.ServiceModel
open Microsoft.Xrm.Sdk
open Microsoft.Xrm.Sdk.Client
open Microsoft.Xrm.Sdk.Query
// Set up SDK Client
let auth = new AuthenticationCredentials()
do auth.ClientCredentials.UserName.UserName <- cfg.usrDev
do auth.ClientCredentials.UserName.Password <- cfg.pwdDev
let manager =
ServiceConfigurationFactory.CreateManagement<IOrganizationService>
(cfg.wsdlDev')
let token = manager.Authenticate(auth)
// Define a SDK proxy function that is based on the Service Manager
// (for parallelism purpouses)
let proxy () =
let proxy' = new OrganizationServiceProxy(manager, token.SecurityTokenResponse)
do proxy'.EnableProxyTypes()
proxy'
// Random module
module Random =
let private r = new Random()
let bit () = r.Next(0,2).ToString()
let hex () = r.Next(0,16).ToString("X")
let number from ``to`` = r.Next(from,``to``).ToString()
let rand () = Random.number (1000*1000) (10*1000*1000) // 1.000.000 - 9.999.999
module Seq = // Helper module to split sequence for parallel purposes
let split size source =
seq {
let r = ResizeArray()
for x in source do
r.Add(x)
if r.Count = size then
yield r.ToArray()
r.Clear()
if r.Count > 0 then yield r.ToArray()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment