Angular lazy loading module: warning can't bind to 'ngForOf' since it isn't a known property of 'li' => the li was be not render
Solutions: Add Component to Module
23 tháng 6, 2020
5 tháng 8, 2019
net core handle file upload from angular
HTML
<button style="margin-bottom:10px;" mat-raised-button color="accent" (click)="fileUpload.click()">
{{ 'BUYER.UPLOAD_BUTTON' | translate }}
</button>
<input hidden type="file" id="fileToUpload" #fileUpload multiple (change)="handleFileInput($event)"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />
TS
handleFileInput(event) {
swal({
title: "Are you Sure",
type: "warning",
text: "You want to Upload?",
confirmButtonText: "Yes, upload it!?",
showCancelButton: true
}).then(result => {
if (result.value) {
this.loaderService.display(true);
if (event.target.files && event.target.files.length > 0) {
this.fileToUpload = <Array<File>>event.target.files;
debugger;
const fileToUploadForm = new FormData();
if (this.fileToUpload) {
Array.from(this.fileToUpload).forEach(e => {
fileToUploadForm.append("files", e);
});
this.service.uploadToDatabase(fileToUploadForm).subscribe(
data => {
this.loaderService.display(false);
swal({
title: "File Upload with the result as follows:",
type: "success",
html:
'<table cellspacing="15" cellpadding="6" style="display:block;margin-left:auto;margin-right:auto; width:60%">' +
'<tr><td style="background-color:#5ab857"><span style="color:white;">' +
data[0] +
" SUCCESSFULLY INSERTED</span></td></tr>" +
'<tr><td style="background-color:#dcb455"><span style="color:white;">' +
data[1] +
" DUPLICATE RECORD</span></td></tr>" +
'<tr><td style="background-color:#ED1C24"><span style="color:white;">' +
data[2] +
" ERROR IN INSERTING</span><td></tr></table>",
confirmButtonText: "OK"
}).then(result2 => {
if (result2.value) {
setTimeout(_ => this.applyFilter(), 0);
}
});
},
error => {
this.loaderService.display(false);
swal(
"Error",
"Invalid file Format or System Error!<br/> " + error,
"error"
);
setTimeout(_ => this.applyFilter(), 0);
}
);
}
}
}
});
}
CS
public async Task<IActionResult> HandleUpload(List<IFormFile> files)
{
foreach (var formFile in files)
{
var filePath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Files_Upload", formFile.FileName);
if (formFile.Length > 0)
{
using (var stream = new FileStream(filePath, FileMode.Create))
{
await formFile.CopyToAsync(stream);
}
}
}
return Ok(new { count = files.Count });
}
<button style="margin-bottom:10px;" mat-raised-button color="accent" (click)="fileUpload.click()">
{{ 'BUYER.UPLOAD_BUTTON' | translate }}
</button>
<input hidden type="file" id="fileToUpload" #fileUpload multiple (change)="handleFileInput($event)"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />
TS
handleFileInput(event) {
swal({
title: "Are you Sure",
type: "warning",
text: "You want to Upload?",
confirmButtonText: "Yes, upload it!?",
showCancelButton: true
}).then(result => {
if (result.value) {
this.loaderService.display(true);
if (event.target.files && event.target.files.length > 0) {
this.fileToUpload = <Array<File>>event.target.files;
debugger;
const fileToUploadForm = new FormData();
if (this.fileToUpload) {
Array.from(this.fileToUpload).forEach(e => {
fileToUploadForm.append("files", e);
});
this.service.uploadToDatabase(fileToUploadForm).subscribe(
data => {
this.loaderService.display(false);
swal({
title: "File Upload with the result as follows:",
type: "success",
html:
'<table cellspacing="15" cellpadding="6" style="display:block;margin-left:auto;margin-right:auto; width:60%">' +
'<tr><td style="background-color:#5ab857"><span style="color:white;">' +
data[0] +
" SUCCESSFULLY INSERTED</span></td></tr>" +
'<tr><td style="background-color:#dcb455"><span style="color:white;">' +
data[1] +
" DUPLICATE RECORD</span></td></tr>" +
'<tr><td style="background-color:#ED1C24"><span style="color:white;">' +
data[2] +
" ERROR IN INSERTING</span><td></tr></table>",
confirmButtonText: "OK"
}).then(result2 => {
if (result2.value) {
setTimeout(_ => this.applyFilter(), 0);
}
});
},
error => {
this.loaderService.display(false);
swal(
"Error",
"Invalid file Format or System Error!<br/> " + error,
"error"
);
setTimeout(_ => this.applyFilter(), 0);
}
);
}
}
}
});
}
CS
public async Task<IActionResult> HandleUpload(List<IFormFile> files)
{
foreach (var formFile in files)
{
var filePath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Files_Upload", formFile.FileName);
if (formFile.Length > 0)
{
using (var stream = new FileStream(filePath, FileMode.Create))
{
await formFile.CopyToAsync(stream);
}
}
}
return Ok(new { count = files.Count });
}
13 tháng 4, 2019
C# send mail with image attachment and embeded inline
private MailMessage makeupDataForSendMail(string htmlBody, MailMessage mail)
{
string regexImgSrc = @"
]*?src\s*=\s*[""']?([^'"" >]+?)[ '""][^>]*?>";
MatchCollection matchesImgSrc = Regex.Matches(htmlBody, regexImgSrc, RegexOptions.IgnoreCase | RegexOptions.Singleline);
foreach (Match m in matchesImgSrc)
{
string src_url = m.Groups[1].Value;
string pathOfFile = System.Web.HttpContext.Current.Server.MapPath(HttpUtility.UrlDecode(src_url));
var splitPaths = pathOfFile.Split('.');
string extention_file = splitPaths[splitPaths.Length - 1].ToLower();
LinkedResource inline = null;
switch (extention_file)
{
case "gif":
{
inline = new LinkedResource(pathOfFile, MediaTypeNames.Image.Gif);
break;
}
case "png":
{
inline = new LinkedResource(pathOfFile, "image/png");
break;
}
default:
inline = new LinkedResource(pathOfFile, MediaTypeNames.Image.Jpeg);
break;
}
inline.ContentId = Guid.NewGuid().ToString();
htmlBody = htmlBody.Replace(src_url, "cid:" + inline.ContentId);
AlternateView avHtml = AlternateView.CreateAlternateViewFromString
(htmlBody, null, MediaTypeNames.Text.Html);
avHtml.LinkedResources.Add(inline);
mail.AlternateViews.Add(avHtml);
Attachment att = new Attachment(pathOfFile);
att.ContentDisposition.Inline = true;
mail.Attachments.Add(att);
}
return mail;
}
public void sendMail(string htmlBody, string toMail)
{
SmtpClient client = new SmtpClient();
client.Port = int.Parse(this.GetValue("SmtpPort", listVariables));
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("username", "passwrd");
client.Host = this.GetValue("SmtpServer", listVariables);
MailMessage mail = new MailMessage();
mail.From = new MailAddress("frommail");
mail.To.Add(toMail);
mail.Subject = "subject title";
mail.IsBodyHtml = true;
mail = makeupDataForSendMail(htmlBody, mail);
client.Send(mail);
}
Now you can call: sendMail(, "tomail@com" )
{
string regexImgSrc = @"
MatchCollection matchesImgSrc = Regex.Matches(htmlBody, regexImgSrc, RegexOptions.IgnoreCase | RegexOptions.Singleline);
foreach (Match m in matchesImgSrc)
{
string src_url = m.Groups[1].Value;
string pathOfFile = System.Web.HttpContext.Current.Server.MapPath(HttpUtility.UrlDecode(src_url));
var splitPaths = pathOfFile.Split('.');
string extention_file = splitPaths[splitPaths.Length - 1].ToLower();
LinkedResource inline = null;
switch (extention_file)
{
case "gif":
{
inline = new LinkedResource(pathOfFile, MediaTypeNames.Image.Gif);
break;
}
case "png":
{
inline = new LinkedResource(pathOfFile, "image/png");
break;
}
default:
inline = new LinkedResource(pathOfFile, MediaTypeNames.Image.Jpeg);
break;
}
inline.ContentId = Guid.NewGuid().ToString();
htmlBody = htmlBody.Replace(src_url, "cid:" + inline.ContentId);
AlternateView avHtml = AlternateView.CreateAlternateViewFromString
(htmlBody, null, MediaTypeNames.Text.Html);
avHtml.LinkedResources.Add(inline);
mail.AlternateViews.Add(avHtml);
Attachment att = new Attachment(pathOfFile);
att.ContentDisposition.Inline = true;
mail.Attachments.Add(att);
}
return mail;
}
public void sendMail(string htmlBody, string toMail)
{
SmtpClient client = new SmtpClient();
client.Port = int.Parse(this.GetValue("SmtpPort", listVariables));
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("username", "passwrd");
client.Host = this.GetValue("SmtpServer", listVariables);
MailMessage mail = new MailMessage();
mail.From = new MailAddress("frommail");
mail.To.Add(toMail);
mail.Subject = "subject title";
mail.IsBodyHtml = true;
mail = makeupDataForSendMail(htmlBody, mail);
client.Send(mail);
}
Now you can call: sendMail(
27 tháng 9, 2018
[Iphone Lock] Hướng dẫn chặn thông báo cập nhật iOS mới bằng cấu hình của tvOS
Để chặn thông báo cập nhật iOS mới bằng cấu hình của tvOS beta, các bạn làm theo hướng dẫn bên dưới đây:
1. Truy cập vào trang web bdvietnam.com bằng trình duyệt Safari trên thiết bị iOS muốn chặn cập nhật.
2. Kéo xuống dưới và tìm phần cấu hình của tvOS 11, nhấn vào nút Tải về màu xanh.
Lưu ý
Vì cấu hình của tvOS 10 đã hết hạn, nên các bạn có thể tải cấu hình tvOS 11 thay thế cũng được nhé.

3. Ngay lập tức bạn sẽ được chuyển sang ứng dụng Cài đặt, nhấn vào Cài đặt (Install) ở góc trên bên phải để cài cấu hình, nhập mật khẩu của máy (nếu có).

4. Lúc này bạn sẽ được chuyển sang màn hình thông báo của Apple khi cài đặt cấu hình tvOS beta, nhấn tiếp vào Cài đặt (Install) ở góc trên bên phải và cuối cùng là nhấn vào Cài đặt (Install) một lần nữa khi popup hiện ra.

6 tháng 9, 2018
Cài đặt trung tâm tin nhắn cho Iphone
Hiện tại Trên IOS 7 trở về sau trên dòng điện thoại iphone thì không hỗtrợ kiểm tra và thay đổi số trung tâm tin nhắn được nữa
Vì vậy để thực hiện thay đổi số trung tâm tin nhắn trên iphone bạnthực hiện như sau:
Bạn bấm *#5005*7672# rồi nhấn call để kiểm tra số trung tâmtin nhắn
Lúc này màn hình điện thoại sẽ hiện lên Thẩm vấn Cài đặt thành công Địa chỉ số Trung tâm Dịch vụ +84980200030
nếu bạn đang sử dụng mạng Viettel thì màn hinh sẽ hiện lên : Thẩm vấn Cài đặt thành công Địa chỉ số Trung tâm Dịch vụ +84980200030
nếu bạn đang sử dụng mạng Vinaphone. thì màn hinh sẽ hiện lên : Thẩm vấn Cài đặt thành công Địa chỉ số Trung tâm Dịch vụ +8491020005
nếu bạn đang sử dụng mạng Mobifone thì màn hinh sẽ hiện lên : Thẩm vấn Cài đặt thành công Địa chỉ số Trung tâm Dịch vụ +84900000023
Để thay đổi số trung tâm tin nhắn bạn bấm: **5005*7672*+84980200030#
Nếu bạn đang sử dụng là sim viettel
Để thay đổi số trung tâm tin nhắn bạn bấm: **5005*7672*+8491020005#
Nếu bạn đang sử dụng là sim vinaphone
Để thay đổi số trung tâm tin nhắn bạn bấm: **5005*7672*+84900000023#
Nếu bạn đang sử dụng là sim mobifone
Bạn thay đổi thành công máy sẽ thông báo như hình bên dưới
Để chắc chắn bạn bấm *#5005*7672# rồi nhấn call để kiểm tra sốtrung tâm tin nhắn lại một lần nữa.
Vì vậy để thực hiện thay đổi số trung tâm tin nhắn trên iphone bạnthực hiện như sau:
Bạn bấm *#5005*7672# rồi nhấn call để kiểm tra số trung tâmtin nhắn
Lúc này màn hình điện thoại sẽ hiện lên Thẩm vấn Cài đặt thành công Địa chỉ số Trung tâm Dịch vụ +84980200030
nếu bạn đang sử dụng mạng Viettel thì màn hinh sẽ hiện lên : Thẩm vấn Cài đặt thành công Địa chỉ số Trung tâm Dịch vụ +84980200030
nếu bạn đang sử dụng mạng Vinaphone. thì màn hinh sẽ hiện lên : Thẩm vấn Cài đặt thành công Địa chỉ số Trung tâm Dịch vụ +8491020005
nếu bạn đang sử dụng mạng Mobifone thì màn hinh sẽ hiện lên : Thẩm vấn Cài đặt thành công Địa chỉ số Trung tâm Dịch vụ +84900000023
Để thay đổi số trung tâm tin nhắn bạn bấm: **5005*7672*+84980200030#
Nếu bạn đang sử dụng là sim viettel
Để thay đổi số trung tâm tin nhắn bạn bấm: **5005*7672*+8491020005#
Nếu bạn đang sử dụng là sim vinaphone
Để thay đổi số trung tâm tin nhắn bạn bấm: **5005*7672*+84900000023#
Nếu bạn đang sử dụng là sim mobifone
Bạn thay đổi thành công máy sẽ thông báo như hình bên dưới
Để chắc chắn bạn bấm *#5005*7672# rồi nhấn call để kiểm tra sốtrung tâm tin nhắn lại một lần nữa.
19 tháng 6, 2018
15 tháng 11, 2017
Deploy Angular2 on IIS
1. Creating Rewrite Rules for the URL Rewrite Module
- Link: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
2. Build Angular2 Project
ng build --prod --aot(option)
3. Config IIS to dist folder
- Copy dist folder to another folder (ex: deploy)
- Add new Website and pointer to this folder (ex: deploy/dist)
- Add web.config file to the root folder to re-write url (ex: deploy/dist)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Result on IIS
- Link: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
2. Build Angular2 Project
ng build --prod --aot(option)
3. Config IIS to dist folder
- Copy dist folder to another folder (ex: deploy)
- Add new Website and pointer to this folder (ex: deploy/dist)
- Add web.config file to the root folder to re-write url (ex: deploy/dist)
17 tháng 4, 2017
ReactJs Webpack Deploy F5 Not Found Router
Issue:
- Restart your server, It's Ok.
- Run project with command `npm run serve` all router working fine.
- After build with command ` npm run build` and deploy to Apache or Xamp or Wamp, only root "/" router working, other route is not found 404 when Reload page or F5 key press.
Solution:
- Create file .htaccess in the root deploy project(after run build)
- Copy all code below to .htaccess file:
| RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d RewriteRule ^ - [L] RewriteRule ^ /index.html [L] |
1 tháng 3, 2017
Disable scroll of body when scroll to bottom of the child div
PROBLEM
Your body of the web show scroll bar and the child div of body has scroll bar. You want to prevent effect scroll of body when you scroll to the bottom of the child div by mouse wheel.
SOLUTION
Add this lib to the bottom of body: https://rawgit.com/brandonaaron/jquery-mousewheel/master/jquery.mousewheel.js
Origin lib link: https://plugins.jquery.com/mousewheel/
JAVASCRIPT
$(function() {
$('.container-scroll').bind('mousewheel', function(e, d) {
var height=$(e.currentTarget).height(),
scrollHeight= e.currentTarget.scrollHeight;
if((this.scrollTop === (scrollHeight - height) && d < 0) || (this.scrollTop === 0 && d > 0)) {
e.preventDefault();
}
});
});
Your body of the web show scroll bar and the child div of body has scroll bar. You want to prevent effect scroll of body when you scroll to the bottom of the child div by mouse wheel.
SOLUTION
Add this lib to the bottom of body: https://rawgit.com/brandonaaron/jquery-mousewheel/master/jquery.mousewheel.js
Origin lib link: https://plugins.jquery.com/mousewheel/
JAVASCRIPT
$(function() {
$('.container-scroll').bind('mousewheel', function(e, d) {
var height=$(e.currentTarget).height(),
scrollHeight= e.currentTarget.scrollHeight;
if((this.scrollTop === (scrollHeight - height) && d < 0) || (this.scrollTop === 0 && d > 0)) {
e.preventDefault();
}
});
});
22 tháng 1, 2016
Printer Command Language (PCL)
Link tham khảo: https://en.wikipedia.org/wiki/Printer_Command_Language
Send PRN to Printer
- COPY /B C:\FILENAME.PRN \\TP123\LaserJet
12 tháng 6, 2015
IntelliJ HyperLink Xhtml to Spring Bean
Go to File - Project Structure - Modules - Choose which module you want Enable Ctrl + Click from view XHTML to BEAN - Add Spring - Choose Spring and Add Face 'Spring' reference to Application Context.xml - Apply
8 tháng 5, 2015
4 tháng 3, 2015
Liferay LDAP
I.
Hướng
dẫn tạo LDAP AD trong Liferay
1. Cho phép xác thực LDAP
2. Thêm máy chủ LDAP
-
Cấu hình các giá trị kết nối.
-
Khởi động lại hệ thống server để LDAP import các
user về local
-
Mặc định là user_id thay bằng screen_name hoặc email_address
tùy bạn
-
(&(objectCategory=person)(sAMAccountName=@screen_name@))
II.
Tạo mật
khẩu mặc định khi import user từ LDAP
-
ldap.import.user.password.enabled=false
-
ldap.import.user.password.autogenerated=false
ldap.import.user.password.default=test9 tháng 2, 2015
Anh ba hát về cô ba (^_^)
Nắng vàng trôi theo con nước
Tóc ai dài tôi nhớ tôi thương
Gió về Tiền Giang thơm ngát
Nụ cười duyên đôi má hây hây
Lỡ mai này ta chung bước
Cô Ba đừng e thẹn à nghen
Lỡ mai này se tơ tóc
Cô Ba là dâu hiền nhà tôi
Nói thiệt tôi đây không dám
Tôi chỉ cười trong giấc mơ thôi
Nỗi lòng này em đâu biết
Bao ngày qua tôi đếm tương tư
Lỡ mai này không chung bước
Cô Ba về qua nhà người ta
Lỡ mai này tôi không thấy
Tôi sẽ buồn âu sầu mình ên
Đành lòng sao hỡi em
Rượu hồng hoa kết đôi
Thuyền rồng qua bến sông
Cô Ba đành quên rồi người ơi
Thầm gọi trên bến sông
Một người tan giấc mơ
Hỏi rằng con nước trong
Lỡ mai này, lỡ mai này
Người về nơi bến sông xưa
Chiều chiều tôi nhớ mong
Giọt lệ vương áo nâu
Cuộc đời bên luống rau
Cô ba về nơi nhà giàu sang
Chuyện tình tôi trái ngang
Giờ buồn trên bến sông
Dòng Tiền Giang sóng xô
Lỡ mai này, lỡ mai này
Còn gọi 2 tiếng Cô Ba...
5 tháng 2, 2015
HƯỚNG DẪN DOWNLOAD FILE VỚI P:DOWNLOAD
THƯ VIỆN
dependency>
groupId>javax.portlet/groupId>
artifactId>portlet-api/artifactId>
version>2.0/version>
scope>provided/scope>
/dependency>
dependency>
groupId>com.liferay.portal/groupId>
artifactId>portal-service/artifactId>
version>${liferay.version}/version>
scope>provided/scope>
/dependency>
dependency>
groupId>com.liferay.portal/groupId>
artifactId>portal-impl/artifactId>
version>${liferay.version}/version>
scope>provided/scope>
/dependency>
TRONG BEAN
dependency>
groupId>javax.portlet/groupId>
artifactId>portlet-api/artifactId>
version>2.0/version>
scope>provided/scope>
/dependency>
dependency>
groupId>com.liferay.portal/groupId>
artifactId>portal-service/artifactId>
version>${liferay.version}/version>
scope>provided/scope>
/dependency>
dependency>
groupId>com.liferay.portal/groupId>
artifactId>portal-impl/artifactId>
version>${liferay.version}/version>
scope>provided/scope>
/dependency>
TRONG BEAN
public void exportToExcel() {
CellsDataTableMapThongKeHangMucTheoNam cellsDataTableMapThongKeHangMucTheoNam_Moi = new CellsDataTableMapThongKeHangMucTheoNam(hangMucMois, 0);
CellsDataTableMapThongKeHangMucTheoNam cellsDataTableMapThongKeHangMucTheoNam_ChuyenTiep = new CellsDataTableMapThongKeHangMucTheoNam(hangMucChuyenTieps, hangMucMois.size());
WorkbookDesigner designer = new WorkbookDesigner();
try {
String templatePath = FacesContext.getCurrentInstance()
.getExternalContext().getRealPath("/") + File.separator + "TemplateExports" + File.separator + "thongketheonam_in.xlsx";
Workbook workbook = new Workbook(templatePath);
designer.setWorkbook(workbook);
designer.setDataSource("title", "BÁO CÁO HẠNG MỤC SỬ DỤNG NGÂN SÁCH SỰ NGHIỆP THEO NĂM " + namSearch);
designer.setDataSource("namGiaiNgan", "Giải Ngân Năm " + namSearch);
designer.setDataSource("hangmucmoi", cellsDataTableMapThongKeHangMucTheoNam_Moi);
designer.setDataSource("tongHangMucMoi", hangMucMois.size());
designer.setDataSource("tongHangMucChuyenTiep", hangMucChuyenTieps.size());
designer.setDataSource("tongHangMuc", hangMucMois.size() + hangMucChuyenTieps.size());
designer.setDataSource("tongMucDauTuHangMucMoi", tongTongMucDauTuHMMoi);
designer.setDataSource("tongMucDauTuHangMucChuyenTiep", tongTongMucDauTuHMChuyenTiep);
designer.setDataSource("tongMucDauTuHangMuc", tongTongMucDauTuHMMoi + tongTongMucDauTuHMChuyenTiep);
designer.setDataSource("hangmucchuyentiep", cellsDataTableMapThongKeHangMucTheoNam_ChuyenTiep);
designer.process(false);
ByteArrayOutputStream ous = new ByteArrayOutputStream();
designer.getWorkbook().save(ous, SaveFormat.XLSX);
PortletResponse portletResponse = context.getPortletResponse();
HttpServletResponse res = PortalUtil.getHttpServletResponse(portletResponse);
res.setHeader("Content-Disposition", "attachment; filename=\"" + "thongkedanhmuchangmuc.xlsx" + "\"");
res.setHeader("Content-Transfer-Encoding", "binary");
res.setContentType("Content-type: application/vnd.ms-excel");
res.flushBuffer();
OutputStream out = res.getOutputStream();
byte[] buffer = new byte[4096];
int byteread;
InputStream is = new ByteArrayInputStream(ous.toByteArray());
while ((byteread = is.read(buffer)) != -1) {
out.write(buffer, 0, byteread);
buffer = new byte[4096];
}
out.flush();
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
CellsDataTableMapThongKeHangMucTheoNam cellsDataTableMapThongKeHangMucTheoNam_Moi = new CellsDataTableMapThongKeHangMucTheoNam(hangMucMois, 0);
CellsDataTableMapThongKeHangMucTheoNam cellsDataTableMapThongKeHangMucTheoNam_ChuyenTiep = new CellsDataTableMapThongKeHangMucTheoNam(hangMucChuyenTieps, hangMucMois.size());
WorkbookDesigner designer = new WorkbookDesigner();
try {
String templatePath = FacesContext.getCurrentInstance()
.getExternalContext().getRealPath("/") + File.separator + "TemplateExports" + File.separator + "thongketheonam_in.xlsx";
Workbook workbook = new Workbook(templatePath);
designer.setWorkbook(workbook);
designer.setDataSource("title", "BÁO CÁO HẠNG MỤC SỬ DỤNG NGÂN SÁCH SỰ NGHIỆP THEO NĂM " + namSearch);
designer.setDataSource("namGiaiNgan", "Giải Ngân Năm " + namSearch);
designer.setDataSource("hangmucmoi", cellsDataTableMapThongKeHangMucTheoNam_Moi);
designer.setDataSource("tongHangMucMoi", hangMucMois.size());
designer.setDataSource("tongHangMucChuyenTiep", hangMucChuyenTieps.size());
designer.setDataSource("tongHangMuc", hangMucMois.size() + hangMucChuyenTieps.size());
designer.setDataSource("tongMucDauTuHangMucMoi", tongTongMucDauTuHMMoi);
designer.setDataSource("tongMucDauTuHangMucChuyenTiep", tongTongMucDauTuHMChuyenTiep);
designer.setDataSource("tongMucDauTuHangMuc", tongTongMucDauTuHMMoi + tongTongMucDauTuHMChuyenTiep);
designer.setDataSource("hangmucchuyentiep", cellsDataTableMapThongKeHangMucTheoNam_ChuyenTiep);
designer.process(false);
ByteArrayOutputStream ous = new ByteArrayOutputStream();
designer.getWorkbook().save(ous, SaveFormat.XLSX);
PortletResponse portletResponse = context.getPortletResponse();
HttpServletResponse res = PortalUtil.getHttpServletResponse(portletResponse);
res.setHeader("Content-Disposition", "attachment; filename=\"" + "thongkedanhmuchangmuc.xlsx" + "\"");
res.setHeader("Content-Transfer-Encoding", "binary");
res.setContentType("Content-type: application/vnd.ms-excel");
res.flushBuffer();
OutputStream out = res.getOutputStream();
byte[] buffer = new byte[4096];
int byteread;
InputStream is = new ByteArrayInputStream(ous.toByteArray());
while ((byteread = is.read(buffer)) != -1) {
out.write(buffer, 0, byteread);
buffer = new byte[4096];
}
out.flush();
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
TRÊN VIEW
p:commandButton value="#{msgs['btn.indanhsach']}" rendered="#{thongKeDuAnBean.showInDanhSach}" ajax="false" icon="ui-icon-arrowthick-1-s">p:fileDownload value="#{thongKeDuAnBean.exportToExcel()}" /
/p:commandButton
25 tháng 12, 2014
19 tháng 11, 2014
10 tháng 11, 2014
Cài lại Postgres phiên bản cao hơn
Sau khi máy bạn đã cài Postgres thì nếu bạn muốn xóa cài đặt để cài lại postgres với phiện bản mới hơn bạn phải làm động tác này trước khi muốn cài mới.
Run Administrator CMD sau đó gõ lệnh : net user /delete postgres sau đó Enter
Để xóa đi services account
Chúc bạn thành công.
Run Administrator CMD sau đó gõ lệnh : net user /delete postgres sau đó Enter
Để xóa đi services account
Chúc bạn thành công.
10 tháng 10, 2014
HƯỚNG DẪN SỬ DỤNG CÔNG CỤ INTELLIJ BUILD VÀ DEBUG MAVEN PROJECT
1. Tải và cài đặt Intellij
-
Crack tìm trên mạng
2. Import maven project có sẵn
-
Khởi động Intellij lên bạn sẽ thấy rất nhiều tùy
chọn như Create New, Import,… Bạn chọn import à
chọn tới file pom.xml của project à Next cho đến khi kết
thúc.
3. Tạo lệnh build all (tất cả project)
-
Vào menu Run
à Edit Configurations à Click vào dấu + màu xanh chọn
Maven, đặt tên(Name), trỏ tới thư mục
project tổng(Working directory), viết lệnh clean
install ngay dòng Command line à Apply à OK. Nhấn Ctrl + Space nếu quên câu lệnh
4. Tạo lệnh build web
-
Vào menu Run
à Edit Configurations à Click vào dấu + màu xanh chọn
Maven, đặt tên(Name), trỏ tới thư mục
project tổng(Working directory), viết lệnh clean
install package liferay:deploy ngay dòng Command line à Apply à OK. Nhấn Ctrl + Space nếu quên câu lệnh
5. Cấu hình tomcat chạy trong chính
Intellij
-
Vào menu Run
à Edit Configurations à Click vào dấu + màu xanh chọn
Tomcat Server à Local. Ngay tại tab Server
chổ Application server bạn trỏ tới
thư mục server tomcat của mình.
6. Cấu hình debug
-
Sau khi tạo Server Tomcat xong ở bước 5. Bạn chọn
qua thẻ StartUp/Connection.
-
Trỏ chuột tới chổ Run à
xuống chổ Environment Variables.
o
Chọn dấu + tại ô Name gõ vào CATALINA_BASE.
o
Chọn dấu + tại ô Name gõ vào JRE_HOME.
-
Trỏ chuột tới chổ Debug à
xuống chổ Environment Variables.
o
Chọn dấu + tại ô Name gõ vào CATALINA_BASE.
o
Chọn dấu + tại ô Name gõ vào JRE_HOME.
o
Có thêm dòng JAVA_OPTS.
-
Phần Before
Lauch xóa trống hết.
7. Cấu hình Maven home directory
-
Download apache-maven về máy.
Vào menu File
à Settings
à Chọn Maven,
ngay chổ Maven home directory
chúng ta trỏ tới ngay thư mục chứ
apache-maven.
26 tháng 9, 2014
Cách vào thư mục webapps trong server tomcat
Để upload file lên thư mục webapss khi dùng primefaces JSF bạn cần phải xác định thư mục hiện tại(BIN)
public static String workingDir = System.getProperty("user.dir"); // 1 so truong hop bị lỗi khi lên server linus
Cập nhật:
File catalinaBase = new File(System.getProperty("catalina.base")).getAbsoluteFile();
public String workingDir = catalinaBase.getPath();
Ra ngoài thư mục BIN
public static String parentDir = workingDir.substring(0,
workingDir.lastIndexOf(File.separator));// ra ngoai thu muc BIN
Trỏ vào thư mục webapps của server
public static String webappsDir = parentDir + File.separator + "webapps";
Tiến hành upload file vào thư mục này.
Hàm tạo thư mục
public static void createDirectoryIfNeeded(String directoryName)
{
File theDir = new File(directoryName);
// if the directory does not exist, create it
if (!theDir.exists()) {
System.out.println("creating directory: " + directoryName);
theDir.mkdir();
}
}
Như vậy các file upload của bạn sẽ không bị xóa khi restart lại tomcat hay khi build lại source.
Thanks
public static String workingDir = System.getProperty("user.dir"); // 1 so truong hop bị lỗi khi lên server linus
Cập nhật:
File catalinaBase = new File(System.getProperty("catalina.base")).getAbsoluteFile();
public String workingDir = catalinaBase.getPath();
Ra ngoài thư mục BIN
public static String parentDir = workingDir.substring(0,
workingDir.lastIndexOf(File.separator));// ra ngoai thu muc BIN
Trỏ vào thư mục webapps của server
public static String webappsDir = parentDir + File.separator + "webapps";
Tiến hành upload file vào thư mục này.
Hàm tạo thư mục
public static void createDirectoryIfNeeded(String directoryName)
{
File theDir = new File(directoryName);
// if the directory does not exist, create it
if (!theDir.exists()) {
System.out.println("creating directory: " + directoryName);
theDir.mkdir();
}
}
Như vậy các file upload của bạn sẽ không bị xóa khi restart lại tomcat hay khi build lại source.
Thanks
10 tháng 7, 2014
Jquery Loader
Tạo hiệu ứng progress khi tải trang với JqueryLoader. Chỉ cần include 2 file này (Sau khi giải nén mới có) thì trang web của bạn sẽ có hiệu ứng.
Source download:
http://www.mediafire.com/download/9cxlsrj0vlm5zzd/JqueryLoader.7z
Source download:
http://www.mediafire.com/download/9cxlsrj0vlm5zzd/JqueryLoader.7z
30 tháng 5, 2014
Webstorm Key
| username: webstorm |
| key |
| ===== LICENSE BEGIN ===== |
| 72149-12042010 |
| 00000cI5EYta7xt""jWOIDohDqQx7S |
| SSsCH4oSb"1Y4edvtuSYyQ"iqGYhuo |
| !8r1Zrqkj"TmWPZ!Eu"puCi6KV2SVe |
| ===== LICENSE END ===== |
22 tháng 5, 2014
Java bỏ dấu chuổi tiếng việt
public static final String SPECIAL_CHARACTERS_TEMP = "àÀảẢãÃáÁạẠăĂằẰẳẲẵẴắẮặẶâÂầẦẩẨẫẪấẤậẬđĐèÈẻẺẽẼéÉẹẸêÊềỀểỂễỄếẾệỆìÌỉỈĩĨíÍịỊòÒỏỎõÕóÓọỌôÔồỒổỔỗỖốỐộỘơƠờỜởỞỡỠớỚợỢùÙủỦũŨúÚụỤưƯừỪửỬữỮứỨựỰýÝ :+\\<>\"*,!?%$=@#~[]`|^";
public static final String REPLACEMENTS_TEMP = "aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAdDeEeEeEeEeEeEeEeEeEeEeEiIiIiIiIiIoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOuUuUuUuUuUuUuUuUuUuUuUyY-___\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
public static char[] SPECIAL_CHARACTERS = SPECIAL_CHARACTERS_TEMP
.toCharArray();
public static char[] REPLACEMENTS = REPLACEMENTS_TEMP.toCharArray();
public static String toUrlFriendly(String s) {
int maxLength = Math.min(s.length(), 236);
char[] buffer = new char[maxLength];
int n = 0;
for (int i = 0; i < maxLength; i++) {
char ch = s.charAt(i);
buffer[n] = removeAccent(ch);
// skip not printable characters
if (buffer[n] > 31) {
n++;
}
}
// skip trailing slashes
while (n > 0 && buffer[n - 1] == '/') {
n--;
}
return String.valueOf(buffer, 0, n);
}
public static char removeAccent(char ch) {
int index = SPECIAL_CHARACTERS_TEMP.indexOf(ch);
if (index >= 0) {
ch = REPLACEMENTS[index];
}
return ch;
}
public static String removeAccent(String s) {
StringBuilder sb = new StringBuilder(s);
for (int i = 0; i < sb.length(); i++) {
sb.setCharAt(i, removeAccent(sb.charAt(i)));
}
return sb.toString();
}
public static final String REPLACEMENTS_TEMP = "aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAdDeEeEeEeEeEeEeEeEeEeEeEiIiIiIiIiIoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOuUuUuUuUuUuUuUuUuUuUuUyY-___\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
public static char[] SPECIAL_CHARACTERS = SPECIAL_CHARACTERS_TEMP
.toCharArray();
public static char[] REPLACEMENTS = REPLACEMENTS_TEMP.toCharArray();
public static String toUrlFriendly(String s) {
int maxLength = Math.min(s.length(), 236);
char[] buffer = new char[maxLength];
int n = 0;
for (int i = 0; i < maxLength; i++) {
char ch = s.charAt(i);
buffer[n] = removeAccent(ch);
// skip not printable characters
if (buffer[n] > 31) {
n++;
}
}
// skip trailing slashes
while (n > 0 && buffer[n - 1] == '/') {
n--;
}
return String.valueOf(buffer, 0, n);
}
public static char removeAccent(char ch) {
int index = SPECIAL_CHARACTERS_TEMP.indexOf(ch);
if (index >= 0) {
ch = REPLACEMENTS[index];
}
return ch;
}
public static String removeAccent(String s) {
StringBuilder sb = new StringBuilder(s);
for (int i = 0; i < sb.length(); i++) {
sb.setCharAt(i, removeAccent(sb.charAt(i)));
}
return sb.toString();
}
28 tháng 4, 2014
Trang tải các cài đặt mã nguồn mở
Việc cấu hình bằng tay cho source mã nguồn mở thường phức tạp và gặp lỗi. Bạn chỉ cần truy cập vào trang này và down về và cài đặt thông thường như các ứng dụng khác.
https://bitnami.com/stacks
Have a nice day !
https://bitnami.com/stacks
Have a nice day !
15 tháng 4, 2014
Cách tạo mục lục tự động trong word 2007 hoặc 2010
Chọn qua thẻ References và thao tác.
Lưu ý chổ "Add Text", "Table of Contents", "Update Table".
- Add Text: chứa các cấp độ (Level1, Level 2,..) của mục lục, mặc định sẽ có 3 Level.
+ Để add thêm level vào chổ "Add Text": References > Table of Contents > Insert Table of Contents, tìm đến chổ Show levels: mặc định là 3, bạn có thể chọn lên 4,5,6,...
- Đưa các tiêu đề vào tương ứng các level của nó bằng cách bôi đen tiêu đề đó và chọn Add Text vào Level tương ứng:
+ Ví dụ Add Text với cấp độ đầu tiên Level 1
Lưu ý: các định dạng có thể bị thay đổi sau khi Add Text, mình sẽ hướng dẫn cách chỉnh lại sau. tiếp tục...
+ Ví dụ Add Text với cấp độ thứ 2 Level 2.
- Kết quả sau khi chọn sẽ là :
(Cái này mình làm demo nên số trang là 1 hết, đừng lo nhé nếu bài của bạn có nội dung số trang sẽ đúng như trong bài của bạn thôi)
- Trường hợp nếu bạn Add Text nhầm cấp độ hoặc Add thiếu hoặc bạn thêm nôi dung nên mục lục bị thay đổi thì bạn cứ bôi đen các tiêu đề chưa đươc Add đó, rồi Add Text vào. Bây giờ bạn không cần vào chổ Table of Content để chọn Automatic Table 1 hay Automatic Table 2 nữa mà bạn chỉ cần click vào Update Table (nằm gần Table of Contents)
Lưu ý chổ "Add Text", "Table of Contents", "Update Table".
- Add Text: chứa các cấp độ (Level1, Level 2,..) của mục lục, mặc định sẽ có 3 Level.
+ Để add thêm level vào chổ "Add Text": References > Table of Contents > Insert Table of Contents, tìm đến chổ Show levels: mặc định là 3, bạn có thể chọn lên 4,5,6,...
- Đưa các tiêu đề vào tương ứng các level của nó bằng cách bôi đen tiêu đề đó và chọn Add Text vào Level tương ứng:
+ Ví dụ Add Text với cấp độ đầu tiên Level 1
+ Ví dụ Add Text với cấp độ thứ 2 Level 2.
- Cứ tương tự như thế Add Text tất cả các tiêu đề mình cần làm mục lục.
- Sau khi add xong tất cả (Nếu thiếu có thể Add sau) ta đưa con trỏ chuột tới chổ ta cần xuất ra mục lục chọn vào "Table of Contents" bạn có thể chọn "Automatic Table 1" hoặc "Automatic Table 2".

(Cái này mình làm demo nên số trang là 1 hết, đừng lo nhé nếu bài của bạn có nội dung số trang sẽ đúng như trong bài của bạn thôi)
- Trường hợp nếu bạn Add Text nhầm cấp độ hoặc Add thiếu hoặc bạn thêm nôi dung nên mục lục bị thay đổi thì bạn cứ bôi đen các tiêu đề chưa đươc Add đó, rồi Add Text vào. Bây giờ bạn không cần vào chổ Table of Content để chọn Automatic Table 1 hay Automatic Table 2 nữa mà bạn chỉ cần click vào Update Table (nằm gần Table of Contents)
- Một hộp thoại hiện ra:
+ Nếu bạn chọn: Update page numbers only thì mục lục của bạn sẽ chỉ cập nhật lại số trang thôi.
+ Nếu bạn chọn: Update entire table thì mục lục sẽ cập nhật lại nôi dung cũng như số trang (Nên chọn cái này).
- Chúc các bạn thành công (^_^). Office 2010
11 tháng 4, 2014
Liferay: How to move default portlet to another section in control panel
Hi all,
This is the code to include your-portlet into control panel in liferay:
"- control-panel-entry-category default has 4 section : my, content, portal, server"
You can insert code above into liferay-portlet.xml.
If the default portlet for example (User Admin,...) then Where liferay-portlet.xml ? This post will help you.
Now, Go to Server (Tomcat) - webapps - ROOT - WEB-INF, You will see liferay-portlet.xml and Here contain all default portlet you want.
Final you only insert code above into what liferay-portlet you want.
Thank you.
This is the code to include your-portlet into control panel in liferay:
"- control-panel-entry-category default has 4 section : my, content, portal, server"
You can insert code above into liferay-portlet.xml.
If the default portlet for example (User Admin,...) then Where liferay-portlet.xml ? This post will help you.
Now, Go to Server (Tomcat) - webapps - ROOT - WEB-INF, You will see liferay-portlet.xml and Here contain all default portlet you want.
Final you only insert code above into what liferay-portlet you want.
Thank you.
11 tháng 12, 2013
Javascript Validator problem in Eclipse
Right click vào Project chọn Properties chọn xuống chổ Builders sau đó bỏ check chọn chổ JavaScript Validator
7 tháng 12, 2013
Đánh số trang (PageNumber) từ 1 trang bất kỳ.
Ví dụ ở đây bạn muốn đánh trang số 1 bắt đầu từ trang thứ 3
thì làm như sau:
- Đưa con trỏ chuột vào
trang thứ 2, Chọn qua thẻ Page Layout, Chọn Breaks, Chọn Next Page

- Click vào trang thứ 3, Chọn quan thẻ Insert, Chọn Page Number, Chọn Format Page Number

Một hộp thoại hiện ra như sau :
Nhớ chọn giống như hình trên : Start at: 1.
- Chọn nơi để chèn số trang:
Trên (Top of page), Dưới (Bottom of
page),.., Ví dụ mình chọn chính giữa bên dưới
Khi đó số trang sẽ được đánh như sau:
|
Trang thứ 1
|
Đánh số 1
|
|
Trang thứ 2
|
Đánh số 2
|
|
Trang thứ 3
|
Đánh số 1
|
|
Trang thứ 4
|
Đánh số 2
|
|
Trang thứ 5
|
Đánh số 3
|
- Double click vào số 1 ở
trang thứ 3. Click vào nút

để bỏ kết nối giữa các session sau khi mình break (Next Page). - Double click vào số 1 ở
trang thứ nhất xóa số trang này đi thì nó sẽ tự xóa tất cả số trang ở session thứ nhất (Session thứ nhất này mình gồm 2 trang đầu tiên) là xong.
28 tháng 11, 2013
Tomcat không kết nối được mysql
Mô tả lỗi:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have a
n error in your SQL syntax; check the manual that corresponds to your MySQL serv
er version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=DEFAULT' at
line 1
Cách khắc phục:
Cách khắc phục:
- Download Mysql Connector sau đó giải nén thành file .jar bỏ vào thư mục tomcat/lib/ext của tomcat.
- Khởi động lại server tomcat là OK
23 tháng 11, 2013
Mysql port xung đột khi cài Mysql Workbench với Mysql Xampp hoặc Wamp
Khi bạn cài MYSQL WORKBENCH vào cùng với XAMPP hoặc WAMP sẽ xãy ra tình trạng đụng port cơ sở dữ liệu 3306. Vì vậy để khắc phục lỗi này ta tắt 1 trong những dịch vụ.
Sau đây là cách tắt service của MYSQL WORKBENCH để chạy MYSQL XAMPP.
Sau đây là cách tắt service của MYSQL WORKBENCH để chạy MYSQL XAMPP.
- Nhấn tổ hợp phím "Lá cờ (gần nút Alt) + R", sau đó gõ services.msc.
- Tìm tới MySQL56, click chuột phải lên chọn Stop.
- Khởi động lại Mysql Xampp.
Đăng ký:
Bài đăng (Atom)












