Thursday, August 10, 2017

using raspberry samba accounts from windows

login with windows explorer failes sometimes - so use:

net use driveletter uncpath /USER:sambauser

net use z: \\192.168.1.4\varbak /USER:sambauser

OsMc auf Raspy pi

Raspi Pi 1:
- von NTFS (Schwarz weiß) auf PAL umschalten
- Zoom einstellen

Pi3:
Audio von hdmi auf klinkenbuchse umstellen

raspberry sd card backup in image file

dd ... tool zum bitgenauen kopieren von hds usw
if ... in file
of ... out file

mmcblk0 ... sdcard 0


sudo dd if=/dev/mmcblk0 of=./20170810pi3Exp.img

Add Logfile To NLOG Config

        public static void AddLogFileToParent(string subLogDir)
        {
            var logDir = Path.Combine(subLogDir, "..");
            Trace.WriteLine("Adding logfile.txt to" + logDir);
            var config = LogManager.Configuration;

            var logFile = new FileTarget();
            config.AddTarget("file", logFile);

            logFile.FileName = logDir + "\\logfile.txt";
            logFile.Layout = "${date} | ${message}";

            var rule = new LoggingRule("*", LogLevel.Info, logFile);
            config.LoggingRules.Add(rule);

            LogManager.Configuration = config;
        }

init NLOG by Code

        private static  void InitLogger()
        {
            // Step 1. Create configuration object
            var config = new LoggingConfiguration();
            // Step 2. Create targets and add them to the configuration
            var consoleTarget = new ColoredConsoleTarget();
            config.AddTarget("console", consoleTarget);
            var fileTarget = new FileTarget();
            config.AddTarget("file", fileTarget);
            // Step 3. Set target properties
            consoleTarget.Layout = @"${date:format=HH\:mm\:ss} ${logger} ${message}";
            fileTarget.FileName = "${basedir}/file.txt";
            fileTarget.Layout = "${message}";
            // Step 4. Define rules
            var rule1 = new LoggingRule("*", LogLevel.Debug, consoleTarget);
            config.LoggingRules.Add(rule1);
            var rule2 = new LoggingRule("*", LogLevel.Debug, fileTarget);
            config.LoggingRules.Add(rule2);
            // Step 5. Activate the configuration
            LogManager.Configuration = config;
            LogManager.ReconfigExistingLoggers();
        }

MS Unit Test: use TestContext to get current TestName

1) insert Property TestContext into your TestClass - its filled by MSTest:

public TestContext TestContext { get; set; }

2) then use it in TestInitialize

        [TestInitialize]
        public void TestInitialize()
        {
            LOGGER.Info("Initialize Test {0} TestDir={1}", TestContext?.TestName, TestContext?.TestDir);
}


Wednesday, August 09, 2017

c# Lamda Ausdrücke, Action, Func, Anonyme Methoden (noname, keinName)

(x,y) => x*y;  kurz für (x,y) => { return x*y; } kurz für keinName(x,y){return x*y;}

x => x*x; //nur ein Parameter - kann Klammern weglassen

() => 2*3; //kein Parameter - brauche Klammern

(int x, int y) => x*y; //typisierte parameter


aus:
http://www.lernmoment.de/csharp-programmieren/lambda-ausdruecke-erstellen/


// Deklariere ein Delegate
delegate int RechenOperation(int a, int b);

// verwende Lambda um dem delegate eine Anonyme Methode zuzuweisen.
RechenOperation multipliziere = (x, y) => x * y;

// rufe das delegate auf, um es auszuprobieren
int resultat = multipliziere(4, 5);

Action

            var a1 = new Action(p1 => p1++);
            var a2 = new Action((p1) => { p1++; });
a1=a2

            var a3 = new Action(() =>;
                               {
                                   var x = 1;
                                   x++;
                               }
            );

Func

            var f1 = new Func(() => { return 1; });
            var f2 = new Func(() => 2);

Sunday, August 06, 2017

Android 6 SD Karte partitionieren

siehe https://www.droidwiki.org/wiki/HowTo_SD-Karte_Partitionieren

adb shell

sm list-disks adoptable

sm partition disk:179,128 mixed 75

wird dann zu 75% als externe, 25% interner Speicher formatiert

Sunday, July 16, 2017

remote Desktop raspberry pi: sudo apt-get install xrdp

/etc/xrdp/xrdp.ini und /etc/xrdp/sesman.ini.

Thursday, July 06, 2017

Visual Studio Intellisens Shortcuts crtl-space, crtl-shift-space

most important Visual Studio Intellisens Shortcuts:
crtl-space
crtl-shift-space (for parameter info of a function)

raspberry phyton Hello World: first line has to be #!/usr/bin/python

using any text editor like vi, nano:


#!/usr/bin/python

print "Hello, World!";

simple FileSystemWatcher test example


            FileSystemWatcher fsw = new FileSystemWatcher(@"d:\z");
            fsw.Changed += Fsw_Changed;
            fsw.Created += Fsw_Created;
            fsw.Deleted += Fsw_Deleted;
            fsw.Renamed += Fsw_Renamed;
            fsw.EnableRaisingEvents = true;

 

        private void Fsw_Renamed(object sender, RenamedEventArgs e)
        {
            MessageBox.Show($"{e.FullPath} has been renamed");
        }

        private void Fsw_Deleted(object sender, FileSystemEventArgs e)
        {
            MessageBox.Show($"{e.FullPath} has been deleted");
        }

        private void Fsw_Created(object sender, FileSystemEventArgs e)
        {
            MessageBox.Show($"{e.FullPath} has been created");
        }

        private void Fsw_Changed(object sender, FileSystemEventArgs e)
        {
            MessageBox.Show($"{e.FullPath} has changed");
        }

Friday, June 30, 2017

.net typed Datasets: finding out what caused congurency exception

typed datasets have a update command, which has a where clause specifing all original values - easily traced by SQL Server profiler:

'UPDATE [mytable] SET [field1] = @field1, [field2] = @field2
WHERE (([PrimaryKey] = @Original_PrimaryKey) 
AND ((@IsNull_field1 = 1 AND [field1] IS NULL) OR ([field1] = @Original_field1))
AND ((@IsNull_field2 = 1 AND [field2] IS NULL) OR ([field2] = @Original_field2))
'@field1=123, @field2='newStringValue',
@IsNull_field1=0, @Original_field1=1,
@IsNull_fiels2=0, @Original_field2='oldStringValue'

now you can compare the value in the database with the Original_Value from the command and find out which values are differnet - they are blocking.

to do this automatically, you have to catch the exception, get the modified records of the dataset you tried to save, read them again in another dataset and compare those two datasets - (original values)


Wednesday, June 28, 2017

Visual Studio: Custom Tool: Cannot find custom tool ... on this system

try to debug with procmon
filter:
 processname devenv
 path contains your custom tool name


get public key token of assembly

use signtool:
sn -T assemblyname

then use it to reference assambly:
Assembly=assemblyname, Version=1.0.0.0, publicKeyToken=7e3e8edbbbdbe145, Culture=neutral

Visual Studio Custom Tool


https://www.codeproject.com/Tips/1023337/Custom-Tool-Single-File-Generator-for-Visual-Studi

https://www.codeproject.com/search.aspx?q=Custom+Tool&doctypeid=1%3b2%3b3%3b13%3b14

Power Shell Startup Script (profile1, like autoexec.bat)

das autoexec der power shell heißt Microsoft.PowerShell_ profile.ps1 und der PFad dazu ist in $profile gfespeichert.
wenn es noch keines gibt:

# Command to create a PowerShell profile
New-Item -path $profile -type file -force

dann editieren z,.b,:
Set-Location D:\Powershell

http://www.computerperformance.co.uk/powershell/powershell_profile_ps1.htm

Monday, June 26, 2017

path regasm

c:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe

Wednesday, June 21, 2017

VisualStudio Before / After Build Commands

Very simple Execute Command BeforeBuild

   



using built in Variables

needs File Resource1.Designer.cs

   



declaring Variables

   
<resfile>"$(ProjectDir)\\Resource1.Designer.cs"