Posts

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
HOW TO RESOLVE REPORTING SERVICES CATALOG DATABASE FILE EXISTENCE FAILED OR TEMPORARY DATABASE FILE EXISTENCE FAILED Next to go to the Sql server root directory, by default C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA Files to be deleted ReportServer.mdf ReportServer_log.LDF ReportServerTempDB.mdf ReportServerTempDB_log.LDF .

Calling a Web Service from T-SQL

First you need grand  permission Ole Automation Procedures to your server. This can be achived by executing the below sql script sp_configure 'show advanced options', 1  RECONFIGURE; sp_configure 'Ole Automation Procedures', 1  RECONFIGURE;  sp_configure 'show advanced options', 1 RECONFIGURE;  Then the next step is to call a web call. create FUNCTION dbo.WebRequest(@parm VARCHAR(20)) RETURNS VARCHAR(250) AS BEGIN  DECLARE @parmVARCHAR(20)  SET @parm= @parm Declare @Object as Int; Declare @ResponseText as Varchar(8000); Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT; Exec sp_OAMethod @Object, 'open', NULL, 'get', http://www.your.api.call.here', --Your Web Service Url (invoked) 'false' Exec sp_OAMethod @Object, 'send' Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT --Select @ResponseText Exec sp_OADestroy @Object     RETURN @ResponseText END replace the http://www.your.api.call.

Email Providers

Step 1: Get the NuGet  package    Click here... Step 2 :             string userName = "userName ";             string password = "password ";             var data = SmtpConfig.ForSendGrid(userName, password);             SmtpEmailProvider obj = new SmtpEmailProvider(data);             var email = new Email()             {                 ReceiverName = "ReceiverName ",                 ToAddress = "ToAddress @domain.com",                 SenderName = "SenderName",                 FromAddress = "FromAddress @domain.com",                 Message = "Message ",                 Subject = "Subject ",                 IsHtmlEmail = false              };             var re = obj.Send(email); There are many Smtp setting available. ForGoDaddy ForGmail ForOutlook ForMailGun ForSendGrid Happy Coding... :)