Thursday, October 12, 2017

WPF Extrem Simple Viewmodel Binding

namespace WpfExp
{
    public class ViewModel
    {
        public string ViewModelText => "MyViewModelText";
    }
}

XAML:

im Window Tag: WICHTIG nicht DataContect Direkt im Window Tag angeben, sondern extra wie folgt:
<Window.DataContext><local:ViewModel></local:ViewModel></Window.DataContext>

dann nutzen:

<Button Content="{Binding ViewModelText}" Background="Chartreuse" />




Tuesday, October 03, 2017

collapse Regions in visual studio VS 2017

Extras / Optionen / Text Editor / C# / Erweitert
#regions beim Reduzieren auf Definitionen ausblenden


Thursday, September 21, 2017

asp.net

speichern von Infos, die über page lifetime hinausgehen:
session: wenn sie abläuft sind die daten weg
application: wenn recycled weg
viewstate: wird auf client seite gespeichert

hard links windows

https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

Windows 10 auf Hyper V installieren: Genration 2 wählen

Bei Generation 1 kommt:
"Die Microsoft-Software-Lizenzbedingungen wurden nicht gefunden. Stellen Sie sicher, dass die Installationsquellen gültig sind, und starten Sie die Installation erneut."

Bei durch VM mit Generation 2 funktioniert alles perfekt

Wednesday, September 20, 2017

make W10 Install ISO / Stick: https://www.microsoft.com/de-de/software-download/windows10

https://www.microsoft.com/de-de/software-download/windows10

sql Server Commandline Installation

Sql Express Setup from Command Prompt

only required parameters:

only sql server (db)

SETUP.EXE /QUIETSIMPLE /ACTION=Install /FEATURES=SQL /INSTANCENAME=SQLEXPRESS /SQLSVCACCOUNT="NT Authority\System" /SQLSYSADMINACCOUNTS="sqlpc\admin" /AGTSVCACCOUNT="NT Authority\System" /SECURITYMODE=SQL /sapwd="abc!" /IAcceptSQLServerLicenseTerms

with reporting services

SETUP.EXE /QUIETSIMPLE /ACTION=Install /FEATURES=SQL,RS /INSTANCENAME=SQLEXPRESS /SQLSVCACCOUNT="NT Authority\System" /SQLSYSADMINACCOUNTS="sqlPc\admin" /AGTSVCACCOUNT="NT Authority\System" /SECURITYMODE=SQL /sapwd="abc!" /IAcceptSQLServerLicenseTerms

with Directories specified


.\SETUP.EXE /QUIETSIMPLE /ACTION=Install /FEATURES=SQL /INSTANCENAME=SQLEXPRESS /SQLSVCACCOUNT="NT Authority\System" /SQLSYSADMINACCOUNTS="sqlPc\admin" /AGTSVCACCOUNT="NT Authority\System" /SECURITYMODE=SQL /sapwd="abc!" /SQLTEMPDBDIR="C:\sqlData\\" /SQLUSERDBDIR="C:\sqlData\\" /SQLUSERDBLOGDIR="C:\sqlData" /IAcceptSQLServerLicenseTerms


Monday, September 18, 2017

c# LINQ Schreibweise

//SQL Like
var ret1 = from sb in colShiftbooks select new {sb.Id};

//function
var ret2 = colShiftbooks.Select(sb => new {sb.Id});

Wednesday, September 13, 2017

c# Task Error Handling

                mail.SendAsync().ContinueWith(antecedent =>
                                              {
                                                  if (antecedent.IsFaulted)
                                                  {
                                                      _logger.Warn(antecedent.Exception, "Failed sending email");
                                                  }
                                                  else if (antecedent.IsCanceled)
                                                  {
                                                  }
                                                  else
                                                  {
                                                      _logger.Info("Succeed send email");
                                                  }
                                              });

Tuesday, September 12, 2017

EF Entity Framework Reload Entities / Refresh Cache

Reload Entities            


foreach (var entity in Context.ChangeTracker.Entries())
            {
                entity.Reload();
            }

or single entity:
Context.Entry(myEntity).Reload();

Refresh Cache

            var objectContext = ((IObjectContextAdapter)Context).ObjectContext;
            objectContext.Refresh(RefreshMode.StoreWins, Context.MyTable);

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.