Thứ Năm, 26 tháng 10, 2017

Building packages using OctoPack

cd %windir%\Microsoft.NET\Framework\v4.0.30319\ 
msbuild MySolution.sln /t:Build /p:RunOctoPack=true

https://octopus.com/docs/packaging-applications/nuget-packages/using-octopack

Encrypt/Decrypt App.config

 
rename D:\Test\App.config web.config
cd %windir%\Microsoft.NET\Framework\v4.0.30319\
aspnet_regiis -pdf "appSettings" "D:\Test"
rename D:\Test\web.config App.config
pause

Thứ Tư, 25 tháng 10, 2017

Encrypt/Decrypt Web.config

Encrypt:
 
cd %windir%\Microsoft.NET\Framework\v4.0.30319\
aspnet_regiis -pef "appSettings" "D:\Test\"
Decrypt:
 
cd %windir%\Microsoft.NET\Framework\v4.0.30319\
aspnet_regiis -pdf "appSettings" "D:\Test\"

Thứ Hai, 2 tháng 10, 2017

NCalc Custom Functions

        static void Main(string[] argsx)
        {
            Expression e = new Expression("if (And(NOT(ISBLANK(ReceivedDate)), ReceivedDate >= Date(2017,01,01), ReceivedDate <= Date(2018,12,31)), Total * 0.1, Total * VAT)");

            e.Parameters["ReceivedDate"] = DateTime.Parse("2018/01/01");
            e.Parameters["VAT"] = (decimal)12 / 100;
            e.Parameters["Total"] = 1000;

            e.EvaluateFunction += delegate (string name, FunctionArgs args)
            {
                var operatorName = name.ToUpper();
                if (operatorName == "DATE")
                {
                    args.Result = new DateTime((int)args.Parameters[0].Evaluate(), (int)args.Parameters[1].Evaluate(), (int)args.Parameters[2].Evaluate());
                }
                if (operatorName == "AND")
                {
                    args.Result = args.Parameters.All(x => (bool)x.Evaluate());
                }
                if (operatorName == "ISBLANK")
                {
                    var temp = args.Parameters[0].Evaluate();
                    args.Result = temp == null || string.IsNullOrWhiteSpace(temp.ToString());
                }
                if (operatorName == "NOT")
                {
                    args.Result = !(bool)args.Parameters[0].Evaluate();
                }
            };

            var rs = e.Evaluate();
        }