This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<long> UpdateBulk<T>(IMongoCollection<T> _collection, IEnumerable<T> items, FilterDefinition<T> filter, params string[] propertiesToSkip) | |
{ | |
if (!items.Any()) | |
{ | |
return 0; | |
} | |
var updates = new List<WriteModel<T>>(); | |
var filterBuilder = Builders<T>.Filter; | |
var updater = Builders<T>.Update; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void FindLongStrings(object testObject) | |
{ | |
foreach (FieldInfo propInfo in testObject.GetType().GetFields()) | |
{ | |
foreach (ColumnAttribute attribute in propInfo.GetCustomAttributes(typeof(ColumnAttribute), true)) | |
{ | |
if (attribute.DbType.ToLower().Contains("varchar")) | |
{ | |
string dbType = attribute.DbType.ToLower(); | |
int numberStartIndex = dbType.IndexOf("varchar(") + 8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Escape special characters in a string to use in batch file | |
var arg = "^hU$xgjX4ku*Hc0p%#F^UH"; | |
arg.replace(/([\(\)%!\^<>|;, ])/g,'^$1').replace(/&/g, '&&'); | |
console.log(arg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table #d | |
(is_hidden bit NULL, column_ordinal int NULL, name sysname NULL, is_nullable bit NULL, system_type_id int NULL, system_type_name nvarchar(256) NULL, | |
max_length smallint NULL, precision tinyint NULL, scale tinyint NULL, collation_name sysname NULL, user_type_id int NULL, user_type_database sysname NULL, | |
user_type_schema sysname NULL,user_type_name sysname NULL,assembly_qualified_type_name nvarchar(4000),xml_collection_id int NULL,xml_collection_database sysname NULL, | |
xml_collection_schema sysname NULL,xml_collection_name sysname NULL,is_xml_document bit NULL,is_case_sensitive bit NULL,is_fixed_length_clr_type bit NULL, | |
source_server sysname NULL,source_database sysname NULL,source_schema sysname NULL,source_table sysname NULL,source_column sysname NULL,is_identity_column bit NULL, | |
is_part_of_unique_key bit NULL,is_updateable bit NULL,is_computed_column bit NULL,is_sparse_column_set bit NULL,ordinal_in_order_by_list smallint NULL, | |
order_by_list_length smallint NULL,order_by_is_desce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[fnSplitIndexed]( | |
@sInputList VARCHAR(8000) -- List of delimited items | |
, @sDelimiter VARCHAR(8000) = ',' -- delimiter that separates items | |
) RETURNS @List TABLE (idx integer, item VARCHAR(8000)) | |
BEGIN | |
DECLARE @sItem VARCHAR(8000) | |
Declare @idx integer = 0 | |
WHILE CHARINDEX(@sDelimiter,@sInputList,0) <> 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IUnitOfWork<TContext> where TContext: DbContext, new() | |
{ | |
void Commit(); | |
} | |
public interface IDbFactory<TContext> : IDisposable where TContext: DbContext, new() | |
{ | |
TContext Init(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int max(int a, int b) | |
{ | |
/* max(a,b) = 1/2(a + b + |a-b|) */ | |
Func<int, int> modValue = x => (int)Math.Sqrt(Math.Pow(x, 2)); | |
return (int)Math.Ceiling((double)(a + b)/2 + ((double)modValue(a - b))/2); | |
} | |
int min(int a, int b) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To test this script you can use Powershell to write your own test error log entry in the following way: | |
# ------------------------------------- | |
# New-EventLog –LogName Application –Source "Test" | |
# Write-EventLog –LogName Application –Source "Test" –EntryType Error –EventID 1 –Message "This is a test message." | |
# Name to filter the event uses wild card pattern matching | |
$a = "*LocalReport*Application*" | |
#Write-EventLog –LogName Application -Source "Test" –EntryType Error –EventID 1046 –Message "This is a test message for $($a)." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a task to run powershell script on event | |
$cred = Get-Credential | |
$password = $cred.GetNetworkCredential().Password | |
$taskName = "EventMonitoringService" | |
$action = New-ScheduledTaskAction -Execute 'Powershell.exe' -Argument '-NoProfile -WindowStyle Hidden "C:\CourtAlert\Scripts\TakeAction.ps1""' | |
#Remove existing tasks | |
$taskExists = Get-ScheduledTask | Where-Object {$_.TaskName -like $taskName } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$client = "Test" | |
$service="" | |
$EmailBody = "" | |
$EmailSubject = "" | |
$SMTPServer = "relay2" | |
$PCName = $env:COMPUTERNAME | |
$EmailFrom = "$client <[email protected]>" | |
$EmailTo = "[email protected]" |
NewerOlder