port : 6379
- In Local, for Redis, need to create a Redis Server to debug:
-Download server: https://github.com/MicrosoftArchive/redis/releases version 3.2.1
-Unzip on a directory (for example C:\Program Files\RedisServer 5.0)
- cd C:\Program Files\RedisServer 5.0
- redis-server --service-install redis.windows-service.conf --loglevel verbose ßinstall service
- redis-server --service-start ß start Service
- redis-cli.exe ßrun client to check keys (get, set, delete)
-Change in app.config ip for Redis (msHost) with 127.0.0.1
Monday, November 26, 2018
Tuesday, October 9, 2018
Windows Form Application Publish OnceClick
Publish Folder Location : is the path (e.g. C:\Publish\App)
Installation Folder URL : is IIS (e.g. http:\\localhost\AppInstall)
E.g. http://localhost/AppInstall/publish.htm
Assembly Name + Product Name can be make it to different application
Installation Folder URL : is IIS (e.g. http:\\localhost\AppInstall)
E.g. http://localhost/AppInstall/publish.htm
Assembly Name + Product Name can be make it to different application
Friday, June 29, 2018
Git & IONIC
git branch develop
git checkout develop //use
git commit -am "change channel"
git push ionic develop
git checkout master
git merge develop
git commit -am "merge conflict" // checkin local
git push origin // push to server
git push ionic master // push to server
git status
git checkout develop //use
git commit -am "change channel"
git push ionic develop
git checkout master
git merge develop
git commit -am "merge conflict" // checkin local
git push origin // push to server
git push ionic master // push to server
git status
Friday, June 1, 2018
Dowload Attachment From Google Mail using IMAP
//POP is temporary only, so use IMAP better
//Nuget S22.IMAP
using (ImapClient client = new ImapClient("imap.gmail.com", 993, "Email", "App Password", AuthMethod.Login, true))
{
IEnumerable<uint> uids = client.Search(
SearchCondition.From("from@mail")
.And(SearchCondition.SentSince(new DateTime(2018, 05, 01)))
.And(SearchCondition.SentBefore(new DateTime(2018, 06,
01))), "Mail box Name");
Console.WriteLine(uids.Count() + " Emails:");
foreach (var uid in uids)
{
MailMessage message = client.GetMessage(uid,mailbox:"Mail box Name");
Console.WriteLine(message.Subject);
foreach (Attachment
attachment in message.Attachments)
{
byte[] allBytes = new byte[attachment.ContentStream.Length];
int bytesRead =
attachment.ContentStream.Read(allBytes, 0, (int)attachment.ContentStream.Length);
string destinationFile = @"C:\\myfile\\" + attachment.Name;
BinaryWriter writer = new BinaryWriter(new FileStream(destinationFile,
FileMode.OpenOrCreate, FileAccess.Write, FileShare.None));
writer.Write(allBytes);
writer.Close();
}
}
}
Wednesday, May 30, 2018
command not recognized
- Google the correct variable name and path
- set to environment variable
- use ; to add on the value if variable name is same
Tuesday, May 29, 2018
dispatch.yaml
Override routing rules, to specific service.
- Create a dispatch.yaml
- Write Code
dispatch:
- url: '*/favicon.ico'
service: default
- url: 'myurl.com/*'
service: myservice
- url: '*/favicon.ico'
service: default
- url: 'myurl.com/*'
service: myservice
- cd dispatchfilepath
- gcloud config list (check is it in project ?)
- gcloud config set project [myproject] (if u not in project)
- gcloud app deploy dispatch.yaml
Sunday, May 27, 2018
Service Worker
1) is a Javascript file run in background and assists in offline web application.
2) is a cache
2) is a cache
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js')
.then(() => console.log('service worker installed'))
.catch(err => console.error('Error', err));
}
</script>
service-worker.js
var CACHE_VERSION = '0.1.1'; //Update Version
Wednesday, May 16, 2018
Ionic Framework Theory
src/index.html
- Main Entry point of App, set up script and CSS and bootstrap, start running app
- <ion-app></ion-app>
src/app/app.module.ts - entry point for the app (declaration and imports)
src/app/app.component.ts - root component, first component to load
src/app/app.html - template
ionic info - view ionic info
cordova plugin rm cordova-plugin-x-socialsharing --force
cordova plugin add cordova-plugin-x-socialsharing@5.3.2
ionic cordova platform add android@6.3.0
- Main Entry point of App, set up script and CSS and bootstrap, start running app
- <ion-app></ion-app>
src/app/app.module.ts - entry point for the app (declaration and imports)
src/app/app.component.ts - root component, first component to load
src/app/app.html - template
ionic info - view ionic info
cordova plugin rm cordova-plugin-x-socialsharing --force
cordova plugin add cordova-plugin-x-socialsharing@5.3.2
ionic cordova platform add android@6.3.0
Monday, May 7, 2018
ionic framework tutorial
1) npm install -g ionic cordova (-g is means global install)
2) cd to the folder u wan to create the app
3) ionic start helloworld blank (it will generate a folder and files at the path u cd)
5) ionic serve (run your app)
Publish to Android
1) ionic cordova run android --prod --release (cd to IonicProject)
1.1) The file location will at "platforms/andriod/build/output/apk"
*if no work install JAVA 1.8jdk-8u172-windows-x64.exe
* at Environment Variable set JAVA_Home to C:\Program Files\Java\jdk1.8.0_172
2) Create Key store
2.1) cd to c:\Program Files\Java\jdk1.8_0172\bin2.2) keytool -genkey -v -keystore C:\KeyStore/appkey.keystore -alias MyKey -keyalg RSA -keysize 2048 -validity 10000
2.3) Ask password and questions
3) Sign the unasigned APK
3.1) cd to c:\Program Files\Java\jdk1.8_0172\bin
3.2) jarsigner -verbose -keystore c:/keystore/appkey.keystore -storepass [keystorepassword] -keypass [keystorepassword] c:/keystore/app-release-unasigned.apk Mykey
4)Zip Align
4.1) cd to c:\users\[user]\appdata\local\andriod\sdk\build-tools\27.03
4.2) zipalign -v 4 c:/KeyStore/app-release-unsigned.apk c:/KeyStore/MyIonic.apk
2) cd to the folder u wan to create the app
3) ionic start helloworld blank (it will generate a folder and files at the path u cd)
- template : blank, tutorial
5) ionic serve (run your app)
Publish to Android
1) ionic cordova run android --prod --release (cd to IonicProject)
1.1) The file location will at "platforms/andriod/build/output/apk"
*if no work install JAVA 1.8jdk-8u172-windows-x64.exe
* at Environment Variable set JAVA_Home to C:\Program Files\Java\jdk1.8.0_172
2) Create Key store
2.1) cd to c:\Program Files\Java\jdk1.8_0172\bin2.2) keytool -genkey -v -keystore C:\KeyStore/appkey.keystore -alias MyKey -keyalg RSA -keysize 2048 -validity 10000
2.3) Ask password and questions
3) Sign the unasigned APK
3.1) cd to c:\Program Files\Java\jdk1.8_0172\bin
3.2) jarsigner -verbose -keystore c:/keystore/appkey.keystore -storepass [keystorepassword] -keypass [keystorepassword] c:/keystore/app-release-unasigned.apk Mykey
4)Zip Align
4.1) cd to c:\users\[user]\appdata\local\andriod\sdk\build-tools\27.03
4.2) zipalign -v 4 c:/KeyStore/app-release-unsigned.apk c:/KeyStore/MyIonic.apk
Wednesday, May 2, 2018
Connect Cloud SQL through local
1) make sure you are connecting to project
2) cd to cloud_sql_proxy.exe folder path
3)cloud_sql_proxy -instances=[isntancename]=tcp:3308
2) cd to cloud_sql_proxy.exe folder path
3)cloud_sql_proxy -instances=[isntancename]=tcp:3308
make sure port not resuse.
https://cloud.google.com/sql/docs/mysql/quickstart-proxy-test
Tuesday, May 1, 2018
GCP .NET Core Connect MYSQL
1) Authorization set 0.0.0.0/0 (this will allow everyone to connect, to secure it, use SSL (number 2).
2) SSL Connections (Allow SSL connections only)
3) Create Client Certificate (3 File - Client, Key, Server) pem
4) This 3 Files can put in MYSQL workbrench
5) Infra create pfx, this file will put in VS code and password.
6) Appsetting.json
7) Code
2) SSL Connections (Allow SSL connections only)
3) Create Client Certificate (3 File - Client, Key, Server) pem
4) This 3 Files can put in MYSQL workbrench
5) Infra create pfx, this file will put in VS code and password.
6) Appsetting.json
"Connectionstrings": {
"ConnectionApp":"Uid=[id];Pwd=[password];Server=[ip];port=3306;Database=[dbName]",
"SSLCertFile": "[mysql.pfx]",
"SSLCertPassword": "[sslPassword]"
},
7) Code
public MySqlConnection AppConnection()
{
var connectionString = new MySqlConnectionStringBuilder(ConnectionApp)
{
SslMode = MySqlSslMode.Required,
CertificateFile =
System.IO.Path.Combine(Directory.GetCurrentDirectory(), "SSL", SSLCertFile),
CertificatePassword = SSLCertPassword,
AllowUserVariables = true,
};
return new
MySqlConnection(connectionString.ConnectionString);
}
8)Every Method
using (MySqlConnection conn = CargoTrackConnection())
Monday, April 16, 2018
GCP .Net Core Error Reporting
If use Log, it will log duplicate, so just throw exception, code below is throw exception with response 500 and exception class.
//Startup.cs After this
----------------
//Startup.cs After this
app.UseGoogleTrace();
app.UseExceptionHandler(
options =>
{
options.Run(
async context =>
{
context.Response.Headers.Add("Access-Control-Allow-Origin", "*"); //Allow Origin
context.Response.Headers.Add("Access-Control-Allow-Origin", "*"); //Allow Origin
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
context.Response.ContentType = "application/json";
var ex =
context.Features.Get<IExceptionHandlerFeature>();
if (ex != null)
{
var err = JsonConvert.SerializeObject(ex.Error);
await
context.Response.WriteAsync(err).ConfigureAwait(false);
}
});
}
);
//Before this
app.UseMvc();
----------------
try
{
return Ok(result);
}
catch (Exception ex)
{
throw ex;
}
Tuesday, April 3, 2018
JS part 2
//Get From JSON , FIlter , and put in drop down
$.getJSON('https://fly.com/stations/file.json', function (list) {
$.getJSON('https://fly.com/stations/file.json', function (list) {
list = list.filter(function (item) {
return item.StationType == "A";
});
for (var i in list) {
if
(list.hasOwnProperty(i)) {
optionDes += "<option
value='" + list[i].StationCode + "'>" + list[i].StationName
+ "
(" +
list[i].StationCode + ")</option>";
}
}
optionDes += "</select>";
document.getElementById("origin").innerHTML
= optionDes;
Tuesday, March 27, 2018
.Net Core MemoryCache
- IMemoryCache is Sticky Session, store in web server (Route all to the same Server)
- Distributed Cache is Non-sticky Session, design for web farm.
- CacheItemPriority.NeverRemove is cache priority
https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory
Sunday, February 4, 2018
Update Not Found Then Insert
UPDATE Table1 SET (...) WHERE Column1='SomeValue'
IF @@ROWCOUNT=0
INSERT INTO Table1 VALUES (...)
IF @@ROWCOUNT=0
INSERT INTO Table1 VALUES (...)
Subscribe to:
Posts (Atom)