recently i need to convert a legacy vb application that using template to load the information from active directory. the legacy use the meaningful name which is not the same as the attribute name in the active directory.
the following link provide detail information on the about the attribute, then i can easily map it with the proper Ldap-Display-Name.
https://msdn.microsoft.com/en-us/library/ms675090%28v=vs.85%29.aspx
For example when i need to get the Cell phone information from Active directory. I can map the CellPhone name from template file with Ldap-Display-Name mobile, then i can replace CellPhone text with the mobile value from active directory.
a blog to share Microsoft technologies Azure, DotNet, SharePoint, SQL Server,JavaScript Framework: Node.JS, Angular, React
Monday, May 30, 2016
How to maintain French characters in various document type read and write operation?
when i need to implement a console app to read and write the french characters in different document type, such as html, txt, and rtf.
since i uses the File.ReadAllText method to load the content into Memory, if i use the ReadAllText method without the Encoding parameters. the french content will be unable to maintained. it will cause the output of write operation with some weird characters.
string fileContent = File.ReadAllText(signatureTemplateFileName, Encoding.Default);
after the content was loaded, then the content will be wrtie to a new file based on the file format.
for HTML file, we should use Unicode Encoding
using (FileStream fs = File.Open(signatureFileName, FileMode.Create, FileAccess.Write, FileShare.None))
{
using (StreamWriter writer = new StreamWriter(fs, Encoding.Unicode))
{
writer.Write(fileContent);
}
}
for RTF file, we should use Default Encoding
using (FileStream fs = File.Open(signatureFileName, FileMode.Create, FileAccess.Write, FileShare.None))
{
using (StreamWriter writer = new StreamWriter(fs, Encoding.Default))
{
writer.Write(fileContent);
}
}
for TXT file, we should use Unicode Encoding
using (FileStream fs = File.Open(signatureFileName, FileMode.Create, FileAccess.Write, FileShare.None))
{
using (StreamWriter writer = new StreamWriter(fs, Encoding.Unicode))
{
writer.Write(fileContent);
}
}
since i uses the File.ReadAllText method to load the content into Memory, if i use the ReadAllText method without the Encoding parameters. the french content will be unable to maintained. it will cause the output of write operation with some weird characters.
string fileContent = File.ReadAllText(signatureTemplateFileName, Encoding.Default);
after the content was loaded, then the content will be wrtie to a new file based on the file format.
for HTML file, we should use Unicode Encoding
using (FileStream fs = File.Open(signatureFileName, FileMode.Create, FileAccess.Write, FileShare.None))
{
using (StreamWriter writer = new StreamWriter(fs, Encoding.Unicode))
{
writer.Write(fileContent);
}
}
for RTF file, we should use Default Encoding
using (FileStream fs = File.Open(signatureFileName, FileMode.Create, FileAccess.Write, FileShare.None))
{
using (StreamWriter writer = new StreamWriter(fs, Encoding.Default))
{
writer.Write(fileContent);
}
}
for TXT file, we should use Unicode Encoding
using (FileStream fs = File.Open(signatureFileName, FileMode.Create, FileAccess.Write, FileShare.None))
{
using (StreamWriter writer = new StreamWriter(fs, Encoding.Unicode))
{
writer.Write(fileContent);
}
}
Friday, May 27, 2016
How to add New line character to the content in Rich Text Format (RTF) document?
we can use \r\n character to represent the newline charcater in text file, and use <BR> in html file.
however both cases do not apply to rtf document. we should use \par \par to represent a break and newline in rtf document.
Tuesday, May 24, 2016
Boston SharePoint Satursday 2016 Coming on September 10 2016
I just found this news on their Facebook, they finally have the date for SharePoint Satursday
I attend this event every year, i got lots of inside news about SharPoint, great infomration on SharePoint technologies.
"Mark your calendars for SPS Boston. This September 10th, 2016 Same place, same time as last year!"
I attend this event every year, i got lots of inside news about SharPoint, great infomration on SharePoint technologies.
"Mark your calendars for SPS Boston. This September 10th, 2016 Same place, same time as last year!"
Friday, May 20, 2016
How to setup a Paging Control for the grid in AngularJS
we can treat the table as the grid in AngularJS. however, we will encounter the performance issue when the number of rows exeed 100 or more.
it is best to use pagination from AngularJs to load only specifc number of records to improve the performan
we can put the following code below the table content. the page control will be properly rendered and ready to use.
<div style="float:right">
<pagination boundary-links="true" max-size="10" items-per-page="itemsPerPage" total-items="totalItems" ng-model="currentPage" class="pagination-sm" previous-text="‹" next-text="›" first-text="«" last-text="»" ng-change="pageChanged()"></pagination>
</div>
you only have to define the values for the following attribute.
total-items: the total number of records that meets the criteria and will be loaded.
ng-model: Page number,which is the number displayed in the paging control. we will use this to determine the rows will be loaded into UI.
max-size: the total number of page number will be shown in the paging control. in my case there is 10, it will show 1 to 10 in the page control. when user click on the advance button, it will show the next 10, like 10 to 20
ng-change: the javascript function to handle the event on user clicks on the page number in the paging control. the table content will be changed and the specifc number of rows will be loaded
in my snippet of code like this
it is best to use pagination from AngularJs to load only specifc number of records to improve the performan
we can put the following code below the table content. the page control will be properly rendered and ready to use.
<div style="float:right">
<pagination boundary-links="true" max-size="10" items-per-page="itemsPerPage" total-items="totalItems" ng-model="currentPage" class="pagination-sm" previous-text="‹" next-text="›" first-text="«" last-text="»" ng-change="pageChanged()"></pagination>
</div>
you only have to define the values for the following attribute.
total-items: the total number of records that meets the criteria and will be loaded.
ng-model: Page number,which is the number displayed in the paging control. we will use this to determine the rows will be loaded into UI.
max-size: the total number of page number will be shown in the paging control. in my case there is 10, it will show 1 to 10 in the page control. when user click on the advance button, it will show the next 10, like 10 to 20
ng-change: the javascript function to handle the event on user clicks on the page number in the paging control. the table content will be changed and the specifc number of rows will be loaded
in my snippet of code like this
$scope.pageChanged = function () { //console.log('Page changed to: ' + $scope.currentPage); myService.getMyTableContentByPageNumber($scope); };
Thursday, May 19, 2016
improved performace in multiple Column search with PATINDEX in SQL
I had a search textbox to filter the grid against multiple data columns in the grid.
It is too quick and easy to use the LIKE clause for immediate solution. as a result, there will be multiple LIKE '%Pattern%' in the where clause in the query. there should be great if we only have small amout of data. the perform will be deteriorated as the data volumn increase dramatically in the table.
it is much nicer to reduce the number of LIKE Clause with PATINDEX function for String search.
PATINDEX('%'+RTRIM(Ltrim(@SearchTerm))+'%',COALESCE(Field1,'') + '|' + COALESCE(Field2,'') + '|'+ COALESCE(Field3,'')+ '|' + COALESCE(Field4,''))>0
Please remember to use the '|' in string concatenation, this approach will solve the search term match with field1 + field2 or any another fields. for example if we have search term 'ABC', and field1 with value A and fields 2 with value BC. then field1 + field2 will be 'ABC', with '|' separator we should have field1 + field2 to be A|BC which will not match with search term.
It is too quick and easy to use the LIKE clause for immediate solution. as a result, there will be multiple LIKE '%Pattern%' in the where clause in the query. there should be great if we only have small amout of data. the perform will be deteriorated as the data volumn increase dramatically in the table.
it is much nicer to reduce the number of LIKE Clause with PATINDEX function for String search.
PATINDEX('%'+RTRIM(Ltrim(@SearchTerm))+'%',COALESCE(Field1,'') + '|' + COALESCE(Field2,'') + '|'+ COALESCE(Field3,'')+ '|' + COALESCE(Field4,''))>0
Please remember to use the '|' in string concatenation, this approach will solve the search term match with field1 + field2 or any another fields. for example if we have search term 'ABC', and field1 with value A and fields 2 with value BC. then field1 + field2 will be 'ABC', with '|' separator we should have field1 + field2 to be A|BC which will not match with search term.
Wednesday, May 11, 2016
Cool Code Editor From Microsoft
I just got this news from one of teammate this morning, Microsoft release a coding tool call Visual Studio Code, which is completely free.
you can download Visual Studio Code from this page
https://code.visualstudio.com/
I posted the screen shot after my installation.
please always remember this useful short cut Ctrl+Shift+P to launch Extension Manager
then you can install all kind of features that require for your own development.
you can download Visual Studio Code from this page
https://code.visualstudio.com/
I posted the screen shot after my installation.
please always remember this useful short cut Ctrl+Shift+P to launch Extension Manager
then you can install all kind of features that require for your own development.
Subscribe to:
Posts (Atom)