Posts

Showing posts with the label .net

Simple way to generate C# class from database table

 Use the below sql script to generate c# model corresponding to the table.   Set @TableName to the name of your table.   declare @TableName sysname = 'TableName' declare @Result varchar (max) = 'public class ' + @TableName + '{' select @Result = @Result + ' public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }' from ( select replace(col.name, ' ' , '_' ) ColumnName, column_id ColumnId, case typ.name when 'bigint' then 'long' when 'binary' then 'byte[]' when 'bit' then 'bool' when 'char' then 'string' when 'date' then 'DateTime' when 'datetime' then 'DateTime' when 'datetime2' then 'DateTime' when 'datetim

Nuget - Encryption using AES algorithm.

 A simple nuget for encrypting and decrypting data using AES algorithm in .NET and C#     Step 1:  Get the NuGet package https://www.nuget.org/packages/Common.Security.AES Set the property with a string Security.CypherPassWord   Security.CypherPassWord = "CypherPassWord";    Step 2: Just call the methode for  Encrypt var encriptByteArray = Encryption.Security.Encrypt(planetext); var encriptHexTest = Encryption.Security.EncryptAsHex(planetext);  Step 3: Just call the methode for  Decrypt    var planetext = Encryption.Security.Decrypt(encriptByteArray);  var planetext = Encryption.Security.DecryptFromHex(encriptHexTest);

Azure Functions – Time Trigger (CRON)

Expression Description runs at 0 * * * * * every minute 09:00:00; 09:01:00; 09:02:00; … 10:00:00 0 */5 * * * * every 5 minutes 09:00:00; 09:05:00 0 0 * * * * every hour (hourly) 09:00:00; 10:00:00; 11:00:00 0 0 */6 * * * every 6 hours 06:00:00; 12:00:00; 18:00:00; 00:00:00 0 0 8-18 * * * every hour between 8-18 08:00:00; 09:00:00; … 18:00:00; 08:00:00 0 0 0 * * * every day (daily) Mar 1, 2017 00:00:00; Mar 2, 2017 00:00:00 0 0 10 * * * every day at 10:00:00 Mar 1, 2017 10:00:00; Mar 2, 2017 10:00:00 0 0 * * * 1-5 every hour on workdays Mar 3 (FRI), 2017 22:00:00; Mar 3 (FRI), 2017 23:00:00; Mar 6 (MON), 2017 00:00:00 0 0 0 * * 0 every sunday (weekly) Mar 5 (SUN), 2017 00:00:00; Mar 12 (SUN), 2017 00:00:00 0 0 9 * * MON every monday at 09:00:00 Mar 6 (MON), 2017 09:00:00; Mar 13 (MON), 2017 09:00:00 0 0 0 1 * * every 1st of month (monthly) Mar 1, 2017 00:00:00; Apr 1, 2017 00:00:00; May 1, 2017 00:00:00 0 0 0 1 1 * every 1st of january (yearly) Jan 1, 2017 00:00:00; Jan 1, 2018 00:00:00

Xamarin Forms toaster notification for android and iOS

A simple solution is by using the Dependency Service you can easily get the Toast notification in both Android and iOS.   Create an interface in your Xamarin forms package. public interface IMessage { void LongAlert ( string message ) ; void ShortAlert ( string message ) ; }   Android Project   [ assembly: Xamarin.Forms.Dependency(typeof(MessageAndroid)) ] namespace Your.Namespace { public class MessageAndroid : IMessage { public void LongAlert ( string message ) { Toast.MakeText(Application.Context, message, ToastLength.Long).Show(); } public void ShortAlert ( string message ) { Toast.MakeText(Application.Context, message, ToastLength.Short).Show(); } } }    iOS Project   [ assembly: Xamarin.Forms.Dependency(typeof(MessageIOS)) ] namespace Your.Namespace { public class MessageIOS : IMessage { const double LONG_DELAY = 3.5 ; const double SH

NuGet - Common Security

Step 1: Get the NuGet package  https://www.nuget.org/packages/Common.Security/ Set the property with a string Security.CypherPassWord Security.CypherPassWord = "CypherPassWord"; Call the static method for  Security.Encrypt()  syntax :       Security.Encrypt(planeText,password) Call the static method for  Security.Decrypt()  syntax :       Security.Decrypt(planeText,password)

Type Casting or Type Conversion Methods

Converting one type of data to another type it is also known as Type Casting.     Type Casting are of two types:           1) Implicit conversion                 int num = 2147483647;                 long bigNum = num;         2) Explicit conversion        double x = 1234.7;                int a;                // Cast double to int.                a = (int)x;