Saturday, 4 June 2022
Monday, 22 June 2020
Android Firebase Push Notification in asp.net C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
namespace AnroidPushNotification
{
public class AndriodPushNotification
{
public string SendPushNotificationForAndroidSWithoutImage()
{
PushNotificationParameters parameters = new PushNotificationParameters();
parameters.DeviceId = "Token ID";
parameters.ServerKey = "ServerKey ";
parameters.SenderId = "SenderId";
parameters.RequestTimeOut = 20000;
parameters.Title = "TestTitle";
parameters.SoundEnable = "Enabled";
parameters.NotificationEN = "TestEn";
parameters.NotificationAR = "TestAR";
parameters.Message ="testMessage";
string response;
try
{
WebRequest request = WebRequest.Create("https://fcm.googleapis.com/fcm/send");
request.Timeout = parameters.RequestTimeOut;
request.Method = "Post";
request.ContentType = "application/json";
var data = new
{
//ApplicationId = parameters.ApplicationId,
to = parameters.DeviceId,
priority = "high",
content_available = true,
notification = new
{
title = parameters.Title,
sound = parameters.SoundEnable,
messageAR = parameters.NotificationAR,
messageEN = parameters.NotificationEN
}
};
var json = SerializeAndroidWithoutImage(parameters);
//tracingService.Trace("SendPushNotificationForAndroidWithoutImage: json" + json);
Byte[] byteArray = Encoding.UTF8.GetBytes(json);
request.Headers.Add(string.Format("Authorization:key={0}", parameters.ServerKey));
request.Headers.Add(string.Format("Sender: id={0}", parameters.SenderId));
request.ContentLength = byteArray.Length;
// tracingService.Trace("SendPushNotificationForAndroidWithoutImage : ContentLength" + byteArray.Length);
using (Stream dataStream = request.GetRequestStream())
{
dataStream.Write(byteArray, 0, byteArray.Length);
// tracingService.Trace("SendPushNotificationForAndroidWithoutImage:dataStream " + dataStream.Length);
using (WebResponse webResponse = request.GetResponse())
{
using (Stream dataStreamResponse = webResponse.GetResponseStream())
{
using (StreamReader streamReader = new StreamReader(dataStreamResponse))
{
string sResponseFromServer = streamReader.ReadToEnd();
response = sResponseFromServer;
}
}
}
}
}
catch (Exception ex)
{
response = ex.Message;
}
return response;
}
public string SerializeAndroidWithoutImage(PushNotificationParameters parameters)
{
string result = string.Empty;
result = "{\"to\":\"" + parameters.DeviceId
+ "\",\"data\":{\"title\":\"" + parameters.Title
+ "\",\"body\":\"" + parameters.Message
+ "\",\"sound\":\"" + parameters.SoundEnable
+ "\",\"messageAR\":\"" + parameters.NotificationAR
+ "\",\"messageEN\":\"" + parameters.NotificationEN
+ "\"}}";
return result;
}
}
}
Wednesday, 11 September 2019
Dynamic CRM 365 - Option Set cascading Filtering using Java Script.
function lead_Filter_CustomerType_OnLoad()
{
var customerType = Xrm.Page.getAttribute("inf_customertype").getValue();
if (customerType == 1)
{
Xrm.Page.getControl("inf_leadstatus").removeOption(8); // removeOption use for removing option set value at form load
Xrm.Page.getControl("inf_leadstatus").removeOption(9);
Xrm.Page.getControl("inf_leadstatus").removeOption(10);
Xrm.Page.getControl("inf_leadstatus").removeOption(10);
}
else if(customerType == 2)
{
Xrm.Page.getControl("inf_leadstatus").removeOption(1);
Xrm.Page.getControl("inf_leadstatus").removeOption(2);
Xrm.Page.getControl("inf_leadstatus").removeOption(3);
Xrm.Page.getControl("inf_leadstatus").removeOption(4);
Xrm.Page.getControl("inf_leadstatus").removeOption(5);
Xrm.Page.getControl("inf_leadstatus").removeOption(6);
Xrm.Page.getControl("inf_leadstatus").removeOption(7);
}
}
function lead_Filter_LeadStatusOnLoad()
{
var leadstatus = Xrm.Page.getAttribute("inf_leadstatus").getValue();
if (leadstatus == 8)
{
Xrm.Page.getControl("inf_leadsubstatus").removeOption(4);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(5);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(6);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(7);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(8);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(9);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(10);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(11);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(12);
}
else if (leadstatus == 9)
{
Xrm.Page.getControl("inf_leadsubstatus").removeOption(1);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(2);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(3);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(6);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(7);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(8);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(9);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(10);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(11);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(12);
}
if (leadstatus == 10)
{
Xrm.Page.getControl("inf_leadsubstatus").removeOption(1);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(2);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(3);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(4);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(5);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(11);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(12);
}
if (leadstatus == 11)
{
Xrm.Page.getControl("inf_leadsubstatus").removeOption(1);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(2);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(3);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(4);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(5);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(6);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(7);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(8);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(9);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(10);
}
}
function lead_Filter_CustomerType_OnChange()
{
var customerType = Xrm.Page.getAttribute("inf_customertype").getValue();
var optionSet = Xrm.Page.ui.controls.get("inf_leadstatus");
var optionSetValues = optionSet.getAttribute().getOptions();
optionSet.clearOptions();
if (customerType == 1)
{
optionSetValues.forEach(function (element) {
//using forEach store all option value in eleement
if (element.value == "1")
optionSet.addOption(element);
// addoption use for display option set value at form .
if (element.value == "2")
optionSet.addOption(element);
if (element.value == "3")
optionSet.addOption(element);
if (element.value == "4")
optionSet.addOption(element);
if (element.value == "5")
optionSet.addOption(element);
if (element.value == "6")
optionSet.addOption(element);
if (element.value == "7")
optionSet.addOption(element);
});
}
else if (customerType == 2)
{
optionSetValues.forEach(function (element) {
if (element.value == "8")
optionSet.addOption(element);
if (element.value == "9")
optionSet.addOption(element);
if (element.value == "10")
optionSet.addOption(element);
if (element.value == "11")
optionSet.addOption(element);
});
}
}
function lead_Filter_LeadStatus_onChange()
{
var leadstatus = Xrm.Page.getAttribute("inf_leadstatus").getValue();
var optionSet = Xrm.Page.ui.controls.get("inf_leadsubstatus");
var optionSetValues = optionSet.getAttribute().getOptions();
optionSet.clearOptions();
if (leadstatus == 8)
{
optionSetValues.forEach(function (element) {
if (element.value == "1")
optionSet.addOption(element);
if (element.value == "2")
optionSet.addOption(element);
if (element.value == "3")
optionSet.addOption(element);
});
}
else if (leadstatus == 9)
{
optionSetValues.forEach(function (element) {
if (element.value == "4")
optionSet.addOption(element);
if (element.value == "5")
optionSet.addOption(element);
});
}
else if (leadstatus == 10)
{
optionSetValues.forEach(function (element) {
if (element.value == "6")
optionSet.addOption(element);
if (element.value == "7")
optionSet.addOption(element);
if (element.value == "8")
optionSet.addOption(element);
if (element.value == "9")
optionSet.addOption(element);
if (element.value == "10")
optionSet.addOption(element);
});
}
else if (leadstatus == 11)
{
optionSetValues.forEach(function (element) {
if (element.value == "8")
optionSet.addOption(element);
if (element.value == "11")
optionSet.addOption(element);
if (element.value == "12")
optionSet.addOption(element);
});
}
}
Friday, 4 January 2019
Bubble Sorting C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SortingBubbleSort
{
class Program
{
static void Main(string[] args)
{
//a temporary int, to store a value when switching positions
int temp = 0;
//DATA : list of sortable items
int[] data = { 89, 76, 45, 92, 67, 12, 99 };
for (int outer = 0; outer < data.Length; outer++)
{
for (int inner = 0; inner < data.Length - 1; inner++)
{
////comparison statement
if (data[inner] > data[inner + 1])
{
temp = data[inner + 1];
data[inner + 1] = data[inner];
//switching operation
data[inner] = temp;
}
}
}
//Sorted array
foreach (int i in data)
{
Console.Write("\t{0}",i);
}
Console.Read();
} }
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SortingBubbleSort
{
class Program
{
static void Main(string[] args)
{
//a temporary int, to store a value when switching positions
int temp = 0;
//DATA : list of sortable items
int[] data = { 89, 76, 45, 92, 67, 12, 99 };
for (int outer = 0; outer < data.Length; outer++)
{
for (int inner = 0; inner < data.Length - 1; inner++)
{
////comparison statement
if (data[inner] > data[inner + 1])
{
temp = data[inner + 1];
data[inner + 1] = data[inner];
//switching operation
data[inner] = temp;
}
}
}
//Sorted array
foreach (int i in data)
{
Console.Write("\t{0}",i);
}
Console.Read();
} }
}
output:-
12 45 67 79 89 92 99
Monday, 10 December 2018
Different between var and Dynamic Variable in C#.
var It is introduced C#3.0 Version.
dynamic It is introduced C# 4.0 version
1).Var is statically type of variable, where are dynamic is dynamically type of variable.
2)Errore will be occur at compile time in var, where as error will be occur at runtime
.
3)In var initialization is required at time of declaration. If you not initialize variable it will be throw error at compile time "Implicitly -typed variable must be initialized ". where as dynamic type variable initialization is not required at time of declaration.
4)var does not allow the change variable after assigned value where as dynamic type variable allow be change type after assigned .
5)var support intellisense because it arise errore at compile time where as dynamic type variable not support intelligence because type is unknown runtime.
6)var variable can not be used for properties and return value from function .it is available only locally whereas dynamic variable can be used to create properties and return value from function
dynamic It is introduced C# 4.0 version
1).Var is statically type of variable, where are dynamic is dynamically type of variable.
2)Errore will be occur at compile time in var, where as error will be occur at runtime
.
3)In var initialization is required at time of declaration. If you not initialize variable it will be throw error at compile time "Implicitly -typed variable must be initialized ". where as dynamic type variable initialization is not required at time of declaration.
4)var does not allow the change variable after assigned value where as dynamic type variable allow be change type after assigned .
5)var support intellisense because it arise errore at compile time where as dynamic type variable not support intelligence because type is unknown runtime.
6)var variable can not be used for properties and return value from function .it is available only locally whereas dynamic variable can be used to create properties and return value from function
Saturday, 16 June 2018
How to add auto increament with string of number and letter?
CREATE TABLE [dbo].[tbl_Product](
[Id] [int] IDENTITY(101,1) NOT NULL,
ProductId As 'PRO'+Right('000'+convert (varchar(10),Id),6)persisted,
[ProductName] [nvarchar](100) NULL,
[Quantiy] [int] NULL,
[Price] [decimal](18, 1) NULL,
[CreateOn] [datetime] NULL
) ON [PRIMARY]
Output-
Subscribe to:
Posts (Atom)
Secure and Unsecure configuration in Dynamics CRM 365.
Overview : In Dynamics CRM, when we create a plugin, we sometimes need to pass data to that plugin, instead of writing this data inside the ...
-
Overview : In Dynamics CRM, when we create a plugin, we sometimes need to pass data to that plugin, instead of writing this data inside the ...
-
CRM does not allow direct download of the DLL file from the UI . However, there are several ways to retrieve the plugin DLL from the CRM e...
-
CREATE TABLE [dbo].[tbl_dbLogs]( [LogSerialId] [int] IDENTITY(1,1) NOT NULL, [Error_line] [int] NULL, [ERROR_MESSAGE] [nvarchar](max...