博文

目前显示的是 2018的博文

convertdatatypes

Today found 2 interesting web sites: 1. http://www.convertdatatypes.com/ 2. https://ascii.cl

ReWriteURL and Redirect in net core 2.1

Container: public class HomeController : Controller     {         public IActionResult Index()         {           //1 and 2 are without changing the URL in broswer           //1. HomeController aController = new HomeController();                 return aController.About();           //2.//"PageNotFound" must be in Shared view folder.               return View("PageNotFound").          //3 other changing the URL                 return View("Calls");                 Response.Redirect("c");                 return View("Go");                 Redirect("t");                  RedirectToAction(...);         } } Environment:     <PackageReference Include="Microsoft.AspNetCore.App" />     <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" /> Ref: http://www.advancesharp.com/questions/100/server-transfer-in-mvc-razor

Utils in Java

1.java.lang.System   https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html 2.org.apache.commons.lang.SystemUtils uses it. . getJavaHome().getJavaIoTmpDir().getUserDir().getUserHome() .JAVA_VERSION.OS_NAME.USER_TIMEZONE 3.org.apache.commons.lang.math.NumberUtils   http://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/math/NumberUtils.html  4.org.apache.commons.lang.StringUtils https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringUtils.html 5.org.springframework.beans.BeanUtils https://docs.spring.io/spring-framework/docs/5.1.3.RELEASE/javadoc-api/org/springframework/beans/BeanUtils.html 6.org.apache.commons.beanutils http://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.3/apidocs/index.html http://commons.apache.org/proper/commons-beanutils/

JSON & C#

1. System.Text.Json.Utf8JsonReader ref: https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0  https://github.com/ysharplanguage/FastJsonParser#Overview 2. Newtonsoft.Json library  using NewTonsoft.Json; //Using Manage NuGet Packages installs Newtonsoft.Json .  Cat cat2 = new Cat(){name="hik",age=3};  string s1= Newtonsoft.Json.JsonConvert . SerializeObject (cat2);   Cat   cat3 = JsonConvert . DeserializeObject <Cat>(JSONstr);   string outStr2 = JsonConvert.SerializeObject(cat2); private string CapitalFirstLetter(string s)  {             try             {                 string rs = char.ToUpper(s[0]) + s.Substring(1);                 return rs;             }catch(Exception e) { return s; }  } 3. JavaScriptSerializer   using System.Web.Script.Serialization ;   using System.IO;  //Script.Serialization is in System.Web.Extensions .  //We need to add a reference that is System.Web.Extensions in Assemblies in Reference Manager

center element

<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"></script> <style> .cssAmount{font-size:2em;} .col-center-block {     float: none;     display: table;     margin: 0 auto;     /* margin-left: auto; margin-right: auto; */ } .img-fluid{max-width:100%;height:auto} .rounded{border-radius:.25rem!important}.rounded-top{border-top-left-radius:.25rem!important;border-top-right-radius:.25rem!important} .rounded-right{border-top-right-radius:.25rem!important;border-bottom-right-radius:.25rem!important} .rounded-bottom{border-bottom-right-radius:.25rem!important;border-bottom-left-radius:.25rem!important}. rounded-left{border-top-left-radius:.25rem!important;border-bottom-left-radius:.25rem!important} .rounded-circle{border-radius:50%!important}.rounded-0{border-radius:0!important} .divCenter{text-

log ClosedXML

Microsoft Visual Studio 1. NuGet Package Manager installs ClosedXML that depends DocumentFormat.OpenXml, ExcelNumberFormat, and WindowsBase. 2.using ClosedXML.Excel; using System; using System.Data; using System.Data.OleDb; using System.IO; 3. read .xlsx file using (var workbook = new XLWorkbook(xlsxfile)) { ...   var ws = workbook.Worksheet(1);   foreach (var row in ws.Rows())   {if (!row.IsEmpty()){string cell1 = row.Cell(1).GetValue<string>();                                      object value =row.Cell(1).Value; }   } } 4. OpenFileDialog             using (OpenFileDialog openFileDialog = new OpenFileDialog())             {                 openFileDialog.InitialDirectory = Form1.XlsxInitialDirectory; // "C:\\Users\\jason\\Downloads\\";                 openFileDialog.Filter = "xlsx files (*.xlsx)|*.xlsx"; //"txt files (*.xlsx)|*.xlsx|All files (*.*)|*.*";                 openFileDialog.FilterIndex = 2;                 openFileDialog.R

javascript Alert and url query

<!DOCTYPE html> <html> <head> <style> .alert {     padding: 20px;     background-color: #f44336;     color: white; } .closebtn {     margin-left: 15px;     color: white;     font-weight: bold;     float: right;     font-size: 22px;     line-height: 20px;     cursor: pointer;     transition: 0.3s; } .closebtn:hover {     color: black; } </style> </head> <body> <h2>Alert Messages</h2> <p>Click on the "x" symbol to close the alert message.</p> <div class="alert">   <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>   <strong>Danger!</strong> Indicates a dangerous or potentially negative action. </div> </body> </html> function getQueryVariable ( variable ) { var query = window . location . search . substring ( 1 ); var vars = quer

Assembly in C#

1. using System.Reflection.Assembly System.Reflection.AssemblyName name = System.Reflection.Assembly.GetExecutingAssembly().GetName(); //name is {AssemblyNameInProperties, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null} byte[]  key =  name.GetPublicKey(); 2. reflection Assembly assem = typeof (ExampleClass).Assembly; // Create an object from the assembly, passing in the correct number // and type of arguments for the constructor. Object o = assem.CreateInstance( "Example" , false , BindingFlags.ExactBinding, null , new Object[] { 2 }, null , null ); // Make a late-bound call to an instance method of the object. MethodInfo m = assem.GetType( "Example" ).GetMethod( "SampleMethod" ); Object ret = m.Invoke(o, new Object[] { 42 }); Console.WriteLine( "SampleMethod returned {0}." , ret); reference: docs.microsoft.com/en-us/dotnet/api/system.re

learn Nodejs & Express & MongoDB

Ref: http://lonka.github.io/blog/2016/08/18/ng2/ng2-cli-quickstart/   http://www.imooc.com/article/6179 remove Nodejs del %USERPROFILE%\.npmrc rmdir /s/q "c:\Program Files\nodejs" rmdir /s/q "%APPDATA%\npm" rmdir /s/q "%APPDATA%\npm-cache" 安装 Nodejs v6.2.2(npm3) & Visual Studio Code 安装 npm install -g gulp yo webpack rimraf npm install -g typescript typings angular-cli npm install -g eslint tslint npm install -g angular-cli gulp yo webpack rimraf typescript typings eslint tslint ng new demo1 cd demo1 npm install   --- Error: Cannot find module ‘ exists-sync' 这是 1.0.0-beta8 的 issue ng build ng serve   (-prod 同时关闭 live Reload)   -- http://localhost:4200   -- http://localhost:49152(live Reload ) ng generate component header  //直接在「\app\」下加入一個 Component 名為 header ng generate service search ng build     // 以下命令可以將專案發行至 「 \dist 」 中 Ref: http://lonka.github.io/blog/2016/08/18/ng2/ng2-cli-quick