Get the latest changes from master branch to our branch
below is the command to do rebase on top branch
git pull --rebase origin master
Get the latest changes from master branch to our branch
below is the command to do rebase on top branch
git pull --rebase origin master
<h2 class="text-center" style="margin-top: 0; padding-top: 30px; padding-bottom: 30px; background: radial-gradient(farthest-side circle at 100px 35px, #f6d0ea, #d8f7f8 86%);">Azure SignalR Group Chat</h2>
<div class="container" style="height: calc(100% - 110px);"><div>
background: radial-
SELECT s.StudentId,
s.StudentName,
s.[Message],
[m].MessageType,
[m].[Subject],
[m].[MessageBody]
FROM Student s
CROSS APPLY OPENJSON([Message], '$.Messages') sm
CROSS APPLY OPENJSON(sm.value)
WITH
(
MessageType NVARCHAR(50),
[Subject] NVARCHAR(50),
[MessageBody] NVARCHAR(50)
) AS [m]
--Insert into Student values(1,'TestStudent','{"Messages": [{"MessageType": "Email","Subject": "Payment","MessageBody":"Kindly pay your school bill amount {amount}"},{"MessageType": "Sms","Subject": "Payment","MessageBody":"Kindly pay your school bill amount {amount}"}]}')
How to get Xml Inner node value using c#
<?xml version="1.0"?>
<Document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdtc="urn:hl7-org:sdtc">
<docTime value="19981001064138-0400"/>
</Document>
Dynamic Linq:
namespace System.Linq.Dynamic.Core
https://dynamic-linq.net/
Example in Fiddler:
https://dotnetfiddle.net/GdxsMG
var context = new EntityContext();
// Example 1: Strongly styped = normal LINQ
var example1 = context.Customers
.OrderBy(c => c.City).ThenBy(c => c.CompanyName)
.ToList();
FiddleHelper.WriteTable(example1);
// Example 2: Dynamic
var example2 = context.Customers
.OrderBy("City, CompanyName")
.ToList();
FiddleHelper.WriteTable(example2);
// Example 3: Dynamic
var example3 = context.Customers
.OrderBy("City").ThenBy("CompanyName desc")
.ToList();
FiddleHelper.WriteTable(example3);
// Example 4: Dynamic
var example4 = context.Customers
.OrderBy("City, CompanyName desc")
.ToList();
FiddleHelper.WriteTable(example4);
DECLARE @ AS VARCHAR(MAX) = 'param0,param1,param3,param4'
SELECT VALUE FROM
(
SELECT VALUE , ROW_NUMBER() OVER (ORDER BY (SELECT null)) rn FROM STRING_SPLIT(@, ',')
)x where rn = 3
GO
OR
DECLARE @str VARCHAR(100) = 'param0,param1,param3,param4';
SELECT *
FROM OPENJSON('["' + REPLACE(@str,',','","') + '"]')
-----------
Get value By position in the string:
DECLARE @str VARCHAR(100) = 'param0,param1,param3,param4';
SELECT *
FROM OPENJSON('["' + REPLACE(@str,',','","') + '"]')
WHERE [key]=2;
--------------------------
String_split altenative for string split with position:
DECLARE @dlmt NVARCHAR(10)=N',';
DECLARE @pos INT = 2;
declare @input varchar(max)= 'a,b,c';
SELECT CAST(N'<x>' + REPLACE(@input,@dlmt,N'</x><x>') + N'</x>' AS XML).value('/x[sql:variable("@pos")][1]','nvarchar(max)')
xls ( Excel sheet ) file data import to database using c#
string path = string.Concat(Server.MapPath("~/UploadFileFolder/" + FileUpload1.FileName));
FileUpload1.SaveAs(path);
string excel = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 8.0", path);
using (OleDbConnection con = new OleDbConnection(excel))
{
OleDbCommand cmd = new OleDbCommand("select * from [Sheet1$]", con);
con.Open();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
}
File upload in AngularJs and WebAPI example:
Index.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<style type="text/css">
body {
font-family: Arial;
font-size: 10pt;
}
.thumb {
width: 24px;
height: 24px;
float: none;
position: relative;
top: 7px;
}
form .progress {
line-height: 15px;
}
.progress {
display: inline-block;
width: 100px;
border: 3px groove #ccc;
}
.progress > div {
font-size: smaller;
background-color: red;
width: 0%;
}
</style>
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/danialfarid-angular-file-upload/12.2.13/ng-file-upload.min.js"></script>
<script type="text/javascript">
var app = angular.module('MyApp', ['ngFileUpload'])
app.controller('MyController', function ($scope, Upload, $timeout) {
$scope.SelectedFiles;
$scope.UploadFiles = function (files) {
$scope.SelectedFiles = files;
}
$scope.SaveFiles = function () {
//$scope.SelectedFiles = files;
if ($scope.SelectedFiles && $scope.SelectedFiles.length) {
Upload.upload({
url: '/Home/FileUpload/',
data: {
files: $scope.SelectedFiles
}
}).then(function (response) {
$timeout(function () {
$scope.Result = response.data;
});
}, function (response) {
if (response.status > 0) {
var errorMsg = response.status + ': ' + response.data;
alert(errorMsg);
}
}, function (evt) {
var element = angular.element(document.querySelector('#dvProgress'));
$scope.Progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
element.html('<div style="width: ' + $scope.Progress + '%">' + $scope.Progress + '%</div>');
});
}
};
});
</script>
<div ng-app="MyApp" ng-controller="MyController">
<input type="file" multiple="multiple" ngf-select="UploadFiles($files)" />
<input type="button" value="save" ng-click="SaveFiles()"/>
<hr />
Files:
<ul><li ng-repeat="file in SelectedFiles">{{file.name}}</li></ul>
<div id="dvProgress" class="progress" ng-show="Progress >= 0">
</div>
</div>
</body>
</html>
Upload large files in Angular 2 or more:
For reference:
https://stackoverflow.com/questions/60182054/upload-large-files-using-angular-8-and-net-core-web-api
download files:
https://stackoverflow.com/questions/35138424/how-do-i-download-a-file-with-angular2-or-greater
Generate POCO classes in Asp.net Core:
Step1: Install NuGet packages
The following NuGet packages should be added to work with the SQL Server database and scaffolding. Run these commands in Package Manager Console:
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Step2:
Scaffolding:
ASP.NET Core has a feature called scaffolding, which uses T4 templates to generate code
Run the following scaffold command in Package Manager Console:
Scaffold-DbContext "Server=***sqll.database.windows.net;Initial Catalog=TestDB;Persist Security Info=False;User ID=sa;Password=password1;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" Microsoft.EntityFrameworkCore.SqlServer -force -Schemas "dbo","otherdbo" -OutputDir EFData -Context EFDataContext -DataAnnotations
or (with out schema)
Scaffold-DbContext "Server=***-sql.database.windows.net;Initial Catalog=TestDB;Persist Security Info=False;User ID=sa;Password=password1;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir EFData -Context EFDataContext
Use -force flog to override existing generated classes:
Scaffold-DbContext "Server=***dev-sql.database.windows.net;Initial Catalog=HealthGrid;Persist Security Info=False;User ID=sa;Password=password1;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" Microsoft.EntityFrameworkCore.SqlServer -force -OutputDir EFData -Context ClinicalTrialDataContext
Simply:
Scaffold-DbContext “DataContext “Server=***sql.database.windows.net;Database=TestDb;Integrated Security=True” Microsoft.EntityFrameworkCore.SqlServer -OutputDir EFData"
or
Scaffold-DbContext "Data Source=***-sql.database.windows.net;Initial Catalog=TestDd;Persist Security Info=True;User ID=sa;Password=password1;MultipleActiveResultSets=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir EFData -Context DataContext
Generate for specific table:
Scaffold-DbContext "server=localhost;user=sa;password=pass;database=testdb"
MySql.Data.EntityFrameworkCore -OutputDir EFData
-Tables actor,film,film_actor,language -f
Load Partial view (MVC) into sectionPatient div dynamically using Ajax
<div id="sectionPatient"></div>
var patientInfoUrl = '@Url.Action("ActionName", "ControllerName")';
1. Using Post method
var patientObj = {};
patientObj.LastName = $('#s_txtLastName').val();
patientObj.FirstName = $('#s_txtFirstName').val();
patientObj.PatientBirthDate = $('#s_txtPatientDOB').val();
patientObj.EMail = $('#s_txtEmailAddress').val();
patientObj.MobileNumber = $('#s_txtMobilePhone').val();
$.ajax({
url: patientInfoUrl,
contentType: "application/json; charset=utf-8",
type: 'POST',
dataType: 'html',
data: JSON.stringify(patientObj),
success: function (data) {
$('#sectionPatient').html(data);
},
error: function (ehr) {
console.log(ehr);
}
});
2. using Get method
$('#sectionPatient').load(patientInfoUrl, function () {
});
<div id="divMain">
<img src="#" class="image"/>
</div
#divMain {
position: relative;
width: 200px;
height: 200px;
}
img {
position: absolute;
top: 0;
bottom: 0;
margin: auto;
}
.image {
min-height: 50px
}