forked from unruledboy/SQLMonitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9f6fcf
commit 06696e8
Showing
97 changed files
with
20,241 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
################# | ||
## Eclipse | ||
################# | ||
|
||
*.pydevproject | ||
.project | ||
.metadata | ||
bin/ | ||
tmp/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# CDT-specific | ||
.cproject | ||
|
||
# PDT-specific | ||
.buildpath | ||
|
||
|
||
################# | ||
## Visual Studio | ||
################# | ||
|
||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
|
||
# Build results | ||
|
||
[Dd]ebug/ | ||
[Rr]elease/ | ||
x64/ | ||
build/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
|
||
# MSTest test Results | ||
[Tt]est[Rr]esult*/ | ||
[Bb]uild[Ll]og.* | ||
|
||
*_i.c | ||
*_p.c | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.tmp_proj | ||
*.log | ||
*.vspscc | ||
*.vssscc | ||
.builds | ||
*.pidb | ||
*.log | ||
*.scc | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
*.vspx | ||
|
||
# Guidance Automation Toolkit | ||
*.gpState | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper*/ | ||
*.[Rr]e[Ss]harper | ||
|
||
# TeamCity is a build add-in | ||
_TeamCity* | ||
|
||
# DotCover is a Code Coverage Tool | ||
*.dotCover | ||
|
||
# NCrunch | ||
*.ncrunch* | ||
.*crunch*.local.xml | ||
|
||
# Installshield output folder | ||
[Ee]xpress/ | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish/ | ||
|
||
# Publish Web Output | ||
*.Publish.xml | ||
*.pubxml | ||
*.publishproj | ||
|
||
# NuGet Packages Directory | ||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line | ||
#packages/ | ||
|
||
# Windows Azure Build Output | ||
csx | ||
*.build.csdef | ||
|
||
# Windows Store app package directory | ||
AppPackages/ | ||
|
||
# Others | ||
sql/ | ||
*.Cache | ||
ClientBin/ | ||
[Ss]tyle[Cc]op.* | ||
~$* | ||
*~ | ||
*.dbmdl | ||
*.[Pp]ublish.xml | ||
*.pfx | ||
*.publishsettings | ||
|
||
# RIA/Silverlight projects | ||
Generated_Code/ | ||
|
||
# Backup & report files from converting an old project file to a newer | ||
# Visual Studio version. Backup files are not needed, because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
UpgradeLog*.htm | ||
|
||
# SQL Server files | ||
App_Data/*.mdf | ||
App_Data/*.ldf | ||
|
||
############# | ||
## Windows detritus | ||
############# | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
ehthumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Mac crap | ||
.DS_Store | ||
|
||
|
||
############# | ||
## Python | ||
############# | ||
|
||
*.py[cod] | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist/ | ||
build/ | ||
eggs/ | ||
parts/ | ||
var/ | ||
sdist/ | ||
develop-eggs/ | ||
.installed.cfg | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
|
||
#Translations | ||
*.mo | ||
|
||
#Mr Developer | ||
.mr.developer.cfg | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.IO; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace Xnlab.SQLMon.Common | ||
{ | ||
internal class AES | ||
{ | ||
private static readonly byte[] Key1 = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; | ||
private const string Key = "_XnlabSQLMonitor"; | ||
|
||
internal static string Encrypt(string content) | ||
{ | ||
return Encrypt(content, Key); | ||
} | ||
|
||
internal static string Encrypt(string content, string key) | ||
{ | ||
using (var des = Rijndael.Create()) | ||
{ | ||
var input = Encoding.UTF8.GetBytes(content); | ||
des.Key = Encoding.UTF8.GetBytes(key); | ||
des.IV = Key1; | ||
using (var ms = new MemoryStream()) | ||
{ | ||
using (var cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write)) | ||
{ | ||
cs.Write(input, 0, input.Length); | ||
cs.FlushFinalBlock(); | ||
var result = ms.ToArray(); | ||
cs.Close(); | ||
ms.Close(); | ||
return Convert.ToBase64String(result); | ||
} | ||
} | ||
} | ||
} | ||
|
||
internal static string Decrypt(string content) | ||
{ | ||
return Decrypt(content, Key); | ||
} | ||
|
||
internal static string Decrypt(string content, string key) | ||
{ | ||
using (var des = Rijndael.Create()) | ||
{ | ||
des.Key = Encoding.UTF8.GetBytes(key); | ||
des.IV = Key1; | ||
var input = Convert.FromBase64String(content); | ||
var result = new byte[input.Length]; | ||
using (var ms = new MemoryStream(input)) | ||
{ | ||
using (var cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Read)) | ||
{ | ||
cs.Read(result, 0, result.Length); | ||
cs.Close(); | ||
ms.Close(); | ||
return Encoding.UTF8.GetString(result).TrimEnd('\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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
using Xnlab.SQLMon.Logic; | ||
|
||
namespace Xnlab.SQLMon.Common | ||
{ | ||
public static class Extensions | ||
{ | ||
public static void Invoke(this Control control, Action action) | ||
{ | ||
try | ||
{ | ||
if (control != null && control.IsHandleCreated && !control.IsDisposed) | ||
control.Invoke(action); | ||
} | ||
catch (Exception) | ||
{ | ||
} | ||
} | ||
|
||
public static void LogExceptions(this Task task) | ||
{ | ||
task.ContinueWith(t => | ||
{ | ||
var aggException = t.Exception.Flatten(); | ||
foreach (var exception in aggException.InnerExceptions) | ||
{ | ||
Debug.WriteLine(exception.Message); | ||
} | ||
}, | ||
TaskContinuationOptions.OnlyOnFaulted); | ||
} | ||
|
||
public static string RemoveSpace(this string content) | ||
{ | ||
content = content.Trim('\t'); | ||
while (content.IndexOf(" ") != -1) | ||
{ | ||
content = content.Replace(" ", " "); | ||
} | ||
return content.Trim(); | ||
} | ||
|
||
public static string ParseObjectName(this string line) | ||
{ | ||
line = SubstringTill(line, Utils.MultiCommentStart); | ||
line = SubstringTill(line, Utils.SingleCommentStart); | ||
line = line.Trim('[', ']', ';', ' '); | ||
var schema = QueryEngine.DefaultSchema + QueryEngine.Dot; | ||
if (line.StartsWith(schema)) | ||
line = line.Substring(schema.Length); | ||
line = SubstringTill(line, " "); | ||
line = SubstringTill(line, "("); | ||
return line.Trim(); | ||
} | ||
|
||
public static string SubstringTill(this string line, string separator) | ||
{ | ||
var index = line.IndexOf(separator); | ||
if (index != -1) | ||
return line.Substring(0, index); | ||
else | ||
return line; | ||
} | ||
|
||
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action) | ||
{ | ||
foreach (var item in source) | ||
{ | ||
action(item); | ||
} | ||
} | ||
|
||
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) | ||
{ | ||
var seenKeys = new HashSet<TKey>(); | ||
foreach (var element in source) | ||
{ | ||
if (seenKeys.Add(keySelector(element))) | ||
{ | ||
yield return element; | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Xnlab.SQLMon.Common | ||
{ | ||
public class KeyValue<TK, TV> | ||
{ | ||
public TK Key { get; set; } | ||
public TV Value { get; set; } | ||
|
||
public KeyValue(TK key, TV value) | ||
{ | ||
this.Key = key; | ||
this.Value = value; | ||
} | ||
} | ||
} |
Oops, something went wrong.