meine Sys/Db admin & Developper Notitzen - wer Rechtschreibfehler findet darf sie behalten ... my Sys/Db Admin and developper notes - I don't care about typos
Monday, June 18, 2018
Thursday, June 07, 2018
android debug bridge adb, shell basics Samsung
adb reboot bootloader
adb installieren und starten
entweder android Studio oder sdk installieren, adb.exe ist inC:\Program Files (x86)\Android\android-sdk\platform-tools
adb befehle
adb devices //listet alle verbundenen geräte aufadb shell //linux shell auf android gerät aufmachen
Adb Shell
partitionen
cat /proc/partitionsdf
Wednesday, June 06, 2018
power shell parameter example cmdlet
<#
.SYNOPSIS
Upload a ConfigFile over Default Configuration
.DESCRIPTION
Uploads File with given Path over Default Configuration (is overwritten !!!)
of a Database (default Db) of a sql SERVERINSTANCE (default localhost\sqlexpress)
.EXAMPLE
.\UploadConfigFile.ps1 D:\temp\Configuration.
uploads the file Configuration. over the Default Configuration
.EXAMPLE
.\UploadConfigFile.ps1 D:\temp\Configuration. -ServerInstance myserver -Database db1
uploads the file Configuration. over the Default Configuration on Database db1 of Sql Server myserver
.PARAMETER FilePath
mandatory, file to be uploaded over the default configuration
.PARAMETER Database
optional, name of Database (default=Db)
.PARAMETER ServerInstance
optional, name of Sql Server Instance (default localhost/sqlexpress)
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string]$FilePath,
[string]$Database="Db",
[string]$ServerInstance="localhost\sqlexpress"
)
$sqlCmd="exec UpdateConfigFile '$FilePath'"
Write-Debug "invoke-SqlCmd: $sqlcmd"
Invoke-Sqlcmd -ServerInstance $ServerInstance -Database $Database -Query $sqlCmd -QueryTimeout 65000
Write-Host "File uploaded over Default Configuration !"
.SYNOPSIS
Upload a ConfigFile over Default Configuration
.DESCRIPTION
Uploads File with given Path over Default Configuration (is overwritten !!!)
of a Database (default Db) of a sql SERVERINSTANCE (default localhost\sqlexpress)
.EXAMPLE
.\UploadConfigFile.ps1 D:\temp\Configuration.
uploads the file Configuration. over the Default Configuration
.EXAMPLE
.\UploadConfigFile.ps1 D:\temp\Configuration. -ServerInstance myserver -Database db1
uploads the file Configuration. over the Default Configuration on Database db1 of Sql Server myserver
.PARAMETER FilePath
mandatory, file to be uploaded over the default configuration
.PARAMETER Database
optional, name of Database (default=Db)
.PARAMETER ServerInstance
optional, name of Sql Server Instance (default localhost/sqlexpress)
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string]$FilePath,
[string]$Database="Db",
[string]$ServerInstance="localhost\sqlexpress"
)
$sqlCmd="exec UpdateConfigFile '$FilePath'"
Write-Debug "invoke-SqlCmd: $sqlcmd"
Invoke-Sqlcmd -ServerInstance $ServerInstance -Database $Database -Query $sqlCmd -QueryTimeout 65000
Write-Host "File uploaded over Default Configuration !"
Monday, June 04, 2018
Friday, May 18, 2018
c# CallerMemberName attribute gibt namen der aufrufender methode zurück
private string HelpMe([CallerMemberName] string param = "")
{
return param;
}
Wednesday, May 09, 2018
power shell debug verbose
dir variable:*pref*
$DebugPreference = "Continue"
$VerbosePreference = "Continue"
$DebugPreference = "Continue"
$VerbosePreference = "Continue"
Programmpfad herausfinden in shell (where in cmd oder power shell)
linux / unix: which
windows cmd: where.exe
power shell: where.exe
n powershell muß man where.exe schreiben, da where abkürzung für Where-Object ist
windows cmd: where.exe
power shell: where.exe
n powershell muß man where.exe schreiben, da where abkürzung für Where-Object ist
Monday, May 07, 2018
Getting __MigrationHistory Table
HistoryContext hc = new HistoryContext(myContext.Database.Connection,"dbo");
var migrations = hc.History.ToList();
var migrations = hc.History.ToList();
Monday, April 23, 2018
Thursday, April 19, 2018
simple sql server merge for insert or update for single row
merge targetTableName as target
using (values (@Key)) as source (keyname)
on [Key]=source.keyname
when matched then
update set bla=@bla
when not matched then
insert ([key], bla)
values (@key, @bla)
using (values (@Key)) as source (keyname)
on [Key]=source.keyname
when matched then
update set bla=@bla
when not matched then
insert ([key], bla)
values (@key, @bla)
Flags
[Flags]
public enum SettingFlags : long
{
/// <summary>
/// hidden in config tool for normal users
/// </summary>
myflag = 0b1,
AdvancedSetting = 0b10
}
[NotMapped]
public bool AdvancedSetting
{
get => Flags.HasFlag(SettingFlags.AdvancedSetting);
set => Flags=SetFlag(Flags, value, SettingFlags.AdvancedSetting);
}
public static SettingFlags SetFlag(SettingFlags flags, bool value, SettingFlags flag)
{
if (value)
flags |= flag;
else
flags &= flag;
return flags;
}
oldschool:
private bool GetBit(SettingFlags position)
{
var pos = (byte)position;
var mask = (1 << pos);
var bit = Flags & mask;
return 0<bit ;
}
private void SetBit(bool value, SettingFlags position)
{
var pos = (byte) position;
var mask = (1 << pos);
if (value)
Flags |= mask;
else
Flags &= ~mask;
}
Wednesday, March 07, 2018
Useful Tools and Settings for Visual Studio
Tools -> Options:
Environment -> InternationalSettings
Language
Environment -> General
Color Theme Dark
Environment -> Fonts & Colors -> Inactive Selected Item
xaml editor better visible
Projects and Solutions –> General
Track Active Item in Solution ExplorerTextEditor -> c# -> Advanced
Outlining - Collapse #regions when collapsing to definitionsTools:
Match Margin:
https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.MatchMargin
Monday, March 05, 2018
WinForm bei Bedarf in Gui Task zurück
wichtig: Gui im Gui Thread öffnen !
/// <summary>
/// 1) check if correct thread, if not call in correct thread
/// 2) sets Text of Control c
/// </summary>
/// <param name="c"></param>
/// <param name="text"></param>
public void _SetText(Control c, string text)
{
if (this.InvokeRequired)
this.Invoke(new Action<Control, string>(_SetText), c, text);
else
c.Text = text;
}
public void _SetMax(int max)
{
if (this.InvokeRequired)
this.Invoke(new Action<int>(_SetMax),max);
else
progressBar1.Maximum = max;
}
public void _IncProgressBar()
{
if (this.InvokeRequired)
this.Invoke(new Action(_IncProgressBar));
else
progressBar1.Value += 1;
}
/// <summary>
/// 1) check if correct thread, if not call in correct thread
/// 2) sets Text of Control c
/// </summary>
/// <param name="c"></param>
/// <param name="text"></param>
public void _SetText(Control c, string text)
{
if (this.InvokeRequired)
this.Invoke(new Action<Control, string>(_SetText), c, text);
else
c.Text = text;
}
public void _SetMax(int max)
{
if (this.InvokeRequired)
this.Invoke(new Action<int>(_SetMax),max);
else
progressBar1.Maximum = max;
}
public void _IncProgressBar()
{
if (this.InvokeRequired)
this.Invoke(new Action(_IncProgressBar));
else
progressBar1.Value += 1;
}
longrunning c# Task mit Fehlerbehandlung
var t = new Task(() => { ImportFile(tablename, conStr, ofd.FileName); },TaskCreationOptions.LongRunning);
var nextTask = t.ContinueWith(antecedent =>
{
if (antecedent.IsFaulted)
{
PLog.ShowAndLogError("SqlTools.ImportFile Error: " + antecedent?.Exception?.Message +antecedent?.Exception?.InnerException?.Message);
}
else if (antecedent.IsCanceled)
{
PLog.LogWarning("SqlTools.ImportFile Canceled: ");
}
else
{
PLog.LogInfo("SqlTools.ImportFile succeeded ! ");
}
});
t.Start();
var nextTask = t.ContinueWith(antecedent =>
{
if (antecedent.IsFaulted)
{
PLog.ShowAndLogError("SqlTools.ImportFile Error: " + antecedent?.Exception?.Message +antecedent?.Exception?.InnerException?.Message);
}
else if (antecedent.IsCanceled)
{
PLog.LogWarning("SqlTools.ImportFile Canceled: ");
}
else
{
PLog.LogInfo("SqlTools.ImportFile succeeded ! ");
}
});
t.Start();
Tuesday, February 20, 2018
Visual Studio aktive Datei im Solution Explorer anzeigen
Tools - Options - Projects and Solutions - Track Active Item in Solution Explorer
Friday, February 16, 2018
Monday, February 05, 2018
gamil gruppen bearbeiten
In der Kontaktansicht mehrere Kontkte auswählen, dann erscheint oben ein Gruppenicon, damit kann man die Kontakte zu Gruppen hinzufügen
Saturday, February 03, 2018
linux owndrive, flash
sudo apt-get install flashplugin-installer
sudo apt-get install owncloud-client
Friday, February 02, 2018
creating TPL Tasks c#
Task.Factory.StartNew(() => CalDaysAndSendMail(taskList), TaskCreationOptions.LongRunning);
Task has constructor from Action or Action
Action a = myVoidMethodWithoutParameters;
Task t = new Task(a);
kurz: var t = new Task(myVoidMethodWithoutParameters);
Action
Task t = new Task(a,obj);
void DoSomething(object o)
from https://www.codeproject.com/articles/189374/the-basics-of-task-parallelism-via-c:
// use an Action delegate and named method
Task task1 = new Task(new Action(printMessage));
// use an anonymous delegate
Task task2 = new Task(delegate { printMessage() });
// use a lambda expression and a named method
Task task3 = new Task(() => printMessage());
// use a lambda expression and an anonymous method
Task task4 = new Task(() => { printMessage() });:
private static void printMessage() {
Console.WriteLine("Hello, world!");
}
Thursday, February 01, 2018
Shortcuts
WINDOWS X, C ... Computerverwaltung
WINDOWS I ... neue Systemeinstellungs App
WINDOWS Q Cortana
WINDOWS I ... neue Systemeinstellungs App
WINDOWS Q Cortana
Subscribe to:
Posts (Atom)