หน้าเว็บ

วันพฤหัสบดีที่ 2 มกราคม พ.ศ. 2563

Axapta : Axapta Auto Create Batch List By Call Class By Code

Axapta : Axapta Auto Create Batch List By Call Class By Code
สิ่งที่ต้องการ
- ต้องการสร้าง Batch List ให้เรียกใช้ Class ที่สร้างขึ้นเพื่อเรียกรายงานและส่งเมล์
เป็นอาทิตย์ หรือเป็นเดือน หรือตามที่ต้องการโดยไม่ต้องสร้างเองให้ Code สร้างให้
- Run Batch ไว้ที่เครื่อง Database เมื่อถึงเวลา ให้เรียกรายงานและส่ง รายงาน ทาง Email ให้ผู้เกี่ยวข้อง

ทำโดย
1. สร้าง Class Auto Create Batch List ให้เลือกวันที่ ที่ต้องการ ตัวอย่างใน Code ให้ทำเฉพาะวันอาทิตย์ เวลาห้าทุ่ม
2. สร้าง Class ที่จะเรียก Reports และส่งเมล์ (ต้องมี Dialog ด้วยไม่อย่างนั้น Run Batch จะ Error)
นำ Class ID ในข้อ 2 ไปใส่ใน Code Class สร้าง Batch List ข้อ 1

(ปัจจุบันส่งเมล์ได้เฉพาะ Windows XP และ Windows7 Windows10 Run Register Dll ไม่ผ่าน)

ส่ง Mail : https://porpramarn.blogspot.com/2016/07/axapta-send-mail-to-zimbra.html

Project :
https://drive.google.com/file/d/1OWawJRESBEb1Re_yG3IThRB2c6VJvmm1/view?usp=sharing

วันพุธที่ 1 มกราคม พ.ศ. 2563

Window 10 : Ubuntu + Linux Mount Partition Windows10 Read only.

Window 10 : Ubuntu + Linux Mount Partition Windows10 Read only.

เนื่องจากมีการเปิดโหมด
Turn on fast startup ไว้ ต้อง ปิดก่อนถึงจะสามารถนำไป Mount ใน Linux เพิ่มหรือแก้ไขไฟล์ต่าง ๆ ใน Disk ได้

If it happens in case of dual booting with Windows 10, you need to uncheck turn on fast startup in Control Panel --> Power Options --> Choose what the power buttons do and then shutdown, not reboot. Once it's done properly you'll be able to access the NTFS partitions normally with read/write permissions.

This happens due to the Windows 10 update resets it to the default fast startup which is a form of hibernation.
https://askubuntu.com/questions/70281/why-does-my-ntfs-partition-mount-as-read-only

https://www.linuxuprising.com/2019/01/fix-windows-10-or-8-partition-mounted.html

วันเสาร์ที่ 7 ธันวาคม พ.ศ. 2562

Windows Server 2003 : Windows Server 2003 Update To R2

Windows Server 2003 : Windows Server 2003 Update To R2
DC04 ที่ Copy VMware มาจากเครื่อง Intranet Local Join และ ทำ Domain เสร็จแล้ว แต่ตัว Version ไม่ใช่ Windows Server 2003 R2
ซึ่งต้อง Update ในหนังสือหน้า 23-24
ทำดังนี้
- Backup Snapshots ก่อนทำ
- หาแผ่นที่ใช้ลง ถ้าของแท้ให้เอาแผ่น 2 ใส่ แต่ตัวนี้เป็น skz ให้ mout แผ่น windows server 2003 skz เข้าไปเลย
ในแผ่นจะมี Folder Update R2
พบปัญหาเวลากดที่ Link Update แล้ว Error
Windows 2003 Wizard Another
Application requires a restart of this computer. Before Setup can run, you must restart the computer.
วิธีแก้ต้องลบ registry เข้าไปที่
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
แล้วลบ PendingFileRenameOperations ออก ถึงจะลงได้
- ติดตั้งตามขึ้นตอน เสร็จแล้ว Reboot
จะเป็น Windows Server 2003 R2

- ต้องดู Active Directory schema version ต้องเป็น Version เดียวกัน กับตัว Master
WINDOWS EDITION SCHEMA VERSION
Windows 2000 Server : 13
Windows Server 2003 : 30
Windows Server 2003 R2 : 31
Windows Server 2008 : 44
Windows Server 2008 R2 : 47
Windows Server 2012 : 56
Windows Server 2012 R2 - Preview : 69

โดยใช้คำสั่ง
dsquery * cn=schema,cn=configuration,dc=domain,dc=com -scope base -attr objectVersion"

เปลี่ยนชื่อ Domain และ dc ที่ใช้ จะต้องได้ Version เดียวกัน กับตัว Master

31 เป็นตัว Windows Server 2003 R2 ถ้าไม่ได้เป็นคนตัวตัวต้อง Update Active Directory schema version (ในหนังสือหน้า 24)

https://nolabnoparty.com/en/finding-active-directory-schema-version/

วันจันทร์ที่ 2 ธันวาคม พ.ศ. 2562

mysql Error Set Default Date 0000-00-00 ไม่ได้

mysql Error Set Default Date 0000-00-00 ไม่ได้
เนื่องจาก mysql 5.7 ไม่รองรับให้ใส่วันที่ ที่ไม่ถูกต้อง
https://dzone.com/articles/upgrading-to ... strict-mod

วิธีแก้ต้องแก้ โหมด mysql
Select มาดูได้ด้วยคำสั่ง
  1. SELECT @@SESSION.sql_mode;

ค่า Default
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION


วิธีแก้ ต้องนำค่า NO_ZERO_IN_DATE,NO_ZERO_DATE ออก
  1. SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'


หรือ ก็ได้
  1. SELECT @@GLOBAL.sql_mode;
  2. SET GLOBAL sql_mode = '...';
 

วันพฤหัสบดีที่ 28 พฤศจิกายน พ.ศ. 2562

Ubuntu : Ubuntu 14.04 Update Vmware Tools แล้ว Error

Ubuntu : Ubuntu 14.04 Update Vmware Tools แล้ว Error
https://intranet.sci.com/blog.php?u=3&b=832

root@webax:/tmp/vmware-tools-distrib# ./vmware-install.pl -d
open-vm-tools packages are available from the OS vendor and VMware recommends
using open-vm-tools packages. See http://kb.vmware.com/kb/2073803 for more
information.
Do you still want to proceed with this installation? [no]
INPUT: [no] default


ต้อง run คำสั่ง
  1. ./vmware-install.pl -f


https://kb.vmware.com/s/article/2107676

วันพุธที่ 27 พฤศจิกายน พ.ศ. 2562

Python : Script สำหรับลบข้อความใน Slack อัตโนมัติ

Python : Script สำหรับลบข้อความใน Slack อัตโนมัติ

Run ที่เครื่องที่ออกเน็ต ได้ ในที่นี้ใช้เครื่อง Extranet
1. ติดตั้งโปรแกรม
  1. sudo apt-get install python-pip

2. ติดตั้ง Slack Client
  1. pip install slackclient
3. สร้าง code removeSlack.py
  1. from slackclient import SlackClient
  2. #from time import sleep
  3. import time
  4. #import datetime
  5. from datetime import datetime, timedelta
  6.  
  7. legacy_token = 'xxxxxx'  # don't if you share your code
  8. channel = 'Cxxxxx'  # the id of the channel to delete all msgs inside
  9.  
  10. sc = SlackClient(legacy_token)
  11. response = sc.api_call('channels.info', channel=channel)
  12.  
  13. #oldest_ts = response['channel']['created']
  14. date_days_ago = datetime.now() - timedelta(days=60)
  15. oldest_ts = time.mktime(date_days_ago.timetuple())
  16. print(datetime.fromtimestamp(oldest_ts))
  17.  
  18. date_days_ago = datetime.now() - timedelta(days=30)
  19. latest_ts = time.mktime(date_days_ago.timetuple())
  20. print(datetime.fromtimestamp(latest_ts))
  21.  
  22. response = sc.api_call('channels.history', channel=channel, count=1000, oldest=oldest_ts, latest=latest_ts)
  23. allmsgs = [item['ts'] for item in response['messages']]
  24. print(len(allmsgs))
  25. for msg in allmsgs:
  26.     sc.api_call('chat.delete', channel=channel, ts=msg)
  27.     time.sleep(1)
  28. ########### Chanel Server  ###################
  29. channel = 'Cxxxxx'
  30.  
  31. sc = SlackClient(legacy_token)
  32. response = sc.api_call('channels.info', channel=channel)
  33.  
  34. #oldest_ts = response['channel']['created']
  35. date_days_ago = datetime.now() - timedelta(days=60)
  36. oldest_ts = time.mktime(date_days_ago.timetuple())
  37. print(datetime.fromtimestamp(oldest_ts))
  38.  
  39. date_days_ago = datetime.now() - timedelta(days=30)
  40. latest_ts = time.mktime(date_days_ago.timetuple())
  41. print(datetime.fromtimestamp(latest_ts))
  42.  
  43. response = sc.api_call('channels.history', channel=channel, count=1000, oldest=oldest_ts, latest=latest_ts)
  44. allmsgs = [item['ts'] for item in response['messages']]
  45. print(len(allmsgs))
  46. for msg in allmsgs:
  47.     sc.api_call('chat.delete', channel=channel, ts=msg)
  48.     time.sleep(1)
4. chmod ให้ Run ได้
5. สร้าง Cront ให้ run ตามที่ต้องการในที่นี้ run อาทิตย์ละครั้ง วันจันทร์
0 0 * * 1 python /home/pi/removeSlak.py >> /home/pi/removeSlack.log 2>&1

วันอังคารที่ 26 พฤศจิกายน พ.ศ. 2562

Ubuntu : Ubuntu 18.04 Https Free letsencrypt

Ubuntu : Ubuntu 18.04 Https Free letsencrypt
ที่ต้องมี
1. เครื่องที่จะทำต้องออก Net ได้ เพื่อ Check DNS ข้างนอก
2. ต้องมี Domain ที่ตรวจสอบจาก DNS ข้างนอกได้ เช็คได้ที่
https://check-your-website.server-daten.de/
ถ้าไม่มีจะ Error
root@intranet1804:~# certbot-auto certonly --standalone -d intranettest.sci.com -d www.intranettest.sci.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for intranettest.sci.com
http-01 challenge for www.intranettest.sci.com

Waiting for verification...
Challenge failed for domain intranettest.sci.com
Challenge failed for domain www.intranettest.sci.com
http-01 challenge for intranettest.sci.com
http-01 challenge for www.intranettest.sci.com
Cleaning up challenges
Some challenges have failed.

IMPORTANT NOTES:
- The following errors were reported by the server:

Domain: intranettest.sci.com
Type: dns
Detail: DNS problem: NXDOMAIN looking up A for intranettest.sci.com

Domain: www.intranettest.sci.com
Type: dns
Detail: DNS problem: NXDOMAIN looking up A for
www.intranettest.sci.com
3. Stop apace ก่อน Run Code ไม่อย่างนั้นจะ Error
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for intranettest.com
http-01 challenge for www.intranettest.com
Cleaning up challenges
Problem binding to port 80: Could not bind to IPv4 or IPv6.

IMPORTANT NOTES:
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.

เริ่มติดตั้ง letsencrypt


Step 1 – Prerequisites
Before starting work on this task, I assume you already have:

- Running Ubuntu system with sudo privileges shell access.
- A domain name registered and pointed to your server’s public IP address. For this tutorial, we use example.com and www.example.com, which is pointed to our server.
- Running web server with VirtualHost configured for example.com and www.example.com on Port 80.

Step 2 – Install Let’s Encrypt Client


Download the certbot-auto Let’s Encrypt client and save under /usr/sbin directory. Use the following command to do this.
  1. sudo wget https://dl.eff.org/certbot-auto -O /usr/sbin/certbot-auto
  2. sudo chmod a+x /usr/sbin/certbot-auto

Step 3 – Get a SSL Certificate

Let’s Encrypt do a strong Domain Validation automatically with multiple challenges to verify the ownership of the domain. Once the Certificate Authority (CA) verified the authenticity of your domain, SSL certificate will be issued.
  1. sudo certbot-auto certonly --standalone -d example.com  -d www.example.com

Above command will prompt for an email address, which is used for sending email alerts related to SSL renewal and expiration. Also, asks a few more questions. After completion, it will issue an SSL certificate and will also create a new VirtualHost configuration file on your system.

Step 4 – Check SSL Certificate

If everything goes fine. A new ssl will be issued at below location. Navigate to below directory and view files.
  1. cd /etc/letsencrypt/live/example.com
  2. ls

Files List:
cert.pem
chain.pem
fullchain.pem
privkey.pem

Setp 5 – Configure SSL VirtualHost

Use the following configurations for Apache and Nginx web server. Edit virtual host configuration file and add below entries for the certificate.

Apache:
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem


Step 6 – Configure SSL Auto Renew


In the end, configure the following job on your server crontab to auto-renew SSL certificate if required.

  1. 0 6 30 * * sudo /usr/sbin/certbot-auto -q renew

หรือ
  1. 0 6 30 * * certbot renew --dry-run



Step 7 นำไฟล์ไปใช้ ที่ 000-default.conf
เช่น
<VirtualHost *:80>
ServerName extranet.scivalve.com
Redirect / https://extranet.scivalve.com/
ServerAdmin suwit@scivalve.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =extranet.scivalve.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:443>
ServerName extranet.scivalve.com
DocumentRoot /var/www/extranet
SSLEngine on
ServerAdmin suwit@scivalve.com
<Directory /var/www/extranet/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
SSLCertificateFile /etc/letsencrypt/live/extranet.scivalve.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/extranet.scivalve.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

https://tecadmin.net/install-lets-encrypt-create-ssl-ubuntu/