9/29/2020

Axapta 2009 : Split, Export แบ่งคำด้วย String

 Axapta 2009 : Split, Export แบ่งคำด้วย String

  1. static void Job1(Args _args)
  2. {
  3.     str paramAsStr = "Value 1|Value 2|Value 3";
  4.     container paramAsCon;
  5.     int i;
  6.  
  7.     paramAsCon = str2con(paramAsStr, "|");
  8.    
  9.     for (i=1;i<=conLen(paramAsCon);i++)
  10.     {
  11.         info(conPeek(paramAsCon, i));    
  12.     }
  13. }


ส่วน Version 2012 เป็นต้นมามี Function strSplit
  1. static void Job1(Args _args)
  2. {
  3.     str paramAsStr = "Value 1|Value 2|Value 3";
  4.     List paramAsList;
  5.     ListEnumerator le;
  6.  
  7.     paramAsList = strSplit(paramAsStr, "|");
  8.    
  9.     le = paramAsList.getEnumerator();
  10.     while(le.moveNext())
  11.     {
  12.         info(le.current());    
  13.     }
  14. }

https://www.schweda.net/blog_ax.php?bid=628&wdl=en

Pi : Pi moition camera notification Line Nofity API

 Pi : Pi moition camera notification Line Nofity API
ติดตั้ง motion
https://porpramarn.blogspot.com/2019/02/pi-pi-camera-motion.html

เพิ่มเติม แก้ Motion ให้ไปเรียกใช้งาน ไฟล์ python ที่สร้างขึ้นเมื่อมีการสร้าง Video

  1. nana /etc/motion/motion.conf
แก้ตรง
on_movie_start python3 /home/pi/line.py


Code python ส่ง Line
https://porpramarn.blogspot.com/2020/09/line-python-line-api-notify.html

Code สำเร็จ

  1. import requests, json
  2. import urllib.parse
  3. import sys
  4.  
  5. import glob
  6. import os
  7. import time
  8.  
  9. LINE_ACCESS_TOKEN = "XXXXXXX"
  10.  
  11. URL_LINE = "https://notify-api.line.me/api/notify"
  12.  
  13. def line_text(message):
  14.     msg = urllib.parse.urlencode({"message":message})
  15.     LINE_HEADERS = {'Content-Type':'application/x-www-form-urlencoded',"Authorization":"Bearer "+LINE_ACCESS_TOKEN}
  16.     session = requests.Session()
  17.     session_post = session.post(URL_LINE, headers=LINE_HEADERS, data=msg)
  18.     print(session_post.text)
  19.  
  20. def line_pic(message, path_file):
  21.     file_img = {'imageFile': open(path_file, 'rb')}
  22.     msg = ({'message': message})
  23.     LINE_HEADERS = {"Authorization":"Bearer "+LINE_ACCESS_TOKEN}
  24.     session = requests.Session()
  25.     session_post = session.post(URL_LINE, headers=LINE_HEADERS, files=file_img, data=msg)
  26.     print(session_post.text)
  27.  
  28. list_of_files = glob.glob('/home/pi/Monitor/*.jpg')
  29. latest_file = max(list_of_files, key=os.path.getctime)
  30. #print(latest_file)
  31. text_send = "Motion Detect OD."
  32. line_pic(text_send, latest_file)
  33.  
  34. #//// Delete All File In Folder Monitor ////#
  35. parth = "/home/pi/Monitor/"
  36. for i in os.listdir ( parth ):
  37.     os.remove(parth+i)

Line : Python ส่งรูปเข้า Line API Notify

 Line : Python ส่งรูปเข้า Line API Notify
โปรแกรมที่ต้องใช้ ในเครื่อง rasberry pi
- python 3 ขึ้นไป
- ติดตั้ง

  1. pip install requests

- ติดตั้ง pip
  1. wget "https://bootstrap.pypa.io/get-pip.py"
  2. sudo python get-pip.py


1. เปิดใช้งาน Token ที่ https://notify-bot.line.me/
สามารถทำเป็น User หรือ ทำเป็น Group ก็ได้

2. สร้าง Code python line.py
XXXX คือ Token ที่ได้จากข้อ 1.
Code
  1. import requests, json
  2. import urllib.parse
  3. import sys
  4.  
  5. LINE_ACCESS_TOKEN = "XXXX" #Use Token Or Group Token https://notify-bot.line.me/
  6.  
  7. URL_LINE = "https://notify-api.line.me/api/notify"
  8.  
  9. def line_text(message):
  10.     msg = urllib.parse.urlencode({"message":message})
  11.     LINE_HEADERS = {'Content-Type':'application/x-www-form-urlencoded',"Authorization":"Bearer "+LINE_ACCESS_TOKEN}
  12.     session = requests.Session()
  13.     session_post = session.post(URL_LINE, headers=LINE_HEADERS, data=msg)
  14.     print(session_post.text)
  15.  
  16. def line_pic(message, path_file):
  17.     file_img = {'imageFile': open(path_file, 'rb')}
  18.     msg = ({'message': message})
  19.     LINE_HEADERS = {"Authorization":"Bearer "+LINE_ACCESS_TOKEN}
  20.     session = requests.Session()
  21.     session_post = session.post(URL_LINE, headers=LINE_HEADERS, files=file_img, data=msg)
  22.     print(session_post.text)
  23.  
  24. if __name__ == "__main__":
  25.     if len(sys.argv) < 3:
  26.         # <Linux>
  27.         # python line.py "Test"
  28.         line_text(sys.argv[1])
  29.     else:
  30.         # <Linux>
  31.         # python line.py "Test" "/home/pi/test.jpg"
  32.         line_pic(sys.argv[1], sys.argv[2])


3. ทดลองส่งข้อความ
  1. python3 line_group.py "พบการเคลื่อนไหว"

จะมีข้อความแจ้ง
{"status":200,"message":"ok"}

และมีข้อความส่งไป Line

4. ส่งรูปใช้คำสั่ง
  1. python3 line.py "พบการเคลื่อนไหว" "/home/pi/3923-7.jpg"


ส่วนตัว Line Bot จะส่งได้เฉพาะรูปที่ผ่าน Link และต้องเป็น https เมื่อรูปถูกลบหรือเปลี่ยนชื่อ Line จะไม่สามารถแสดงผลรูป
ข้อจำกับ Line notify ส่งได้เดือนละ 1000 ครั้ง
https://notify-bot.line.me/doc/en/

ตัวอย่าง
https://maker.goisgo.net/raspberry-pi-webcam-cctv-line-notice/
https://medium.com/@dome.soda125/%E0%B8%A1%E0%B8%B2%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-line-notification-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-python-%E0%B8%81%E0%B8%B1%E0%B8%99%E0%B9%80%E0%B8%96%E0%B8%AD%E0%B8%B0-ab8ce98f0bd6
https://medium.com/dolab/blog-7-line-notify-with-python-8c9724796428
https://engineering.linecorp.com/en/blog/using-line-notify-to-send-stickers-and-upload-images/

 

8/25/2020

Axapta : การ Adjust มูลค่าของที่ Onhand เป็น 0 สามารถทำได้

 Axapta : การ Adjust มูลค่าของที่ Onhand เป็น 0 สามารถทำได้
แต่ก่อนเข้าใจว่าถ้ายอดเป็น 0 แล้วมีการ Adjust + Recall จะทำให้รายงาน Inventory ไม่มียอด Onhand แต่จะมีมูลค่า

หลังจากได้ทดลองอีกครั้ง พบว่า สามารถทำได้ เช่น 154360121003
1. หายอด Onhand ที่มียอด เป็น 0 เรียกรายงาน Inventory ไม่มียอดและมูลค่า


2. ทำการ Adjust ต้นทุนเข้าไป และเรียกรายงาน Invent จะพบมียอดเงินแต่ไม่มีของตามรูป
3. ทำการ Recalculation พบว่ามูลค่าที่ค้างอยู่หายไป
และต้นทุน Code อื่น ๆ ที่นำ Item นี้ไปใช้ ก่อน Recalculation


หลัง Call ต้นทุนที่นำ Parts ที่ Adjust ไปใช้ก็จะเปลี่ยนไป

สรุปคือ สามารถทำได้ การที่รายงาน Inventory ไม่มีของแต่มีมูลค่าอาจจะมาจากสาเหตุอื่น

8/19/2020

การ Update Firmware ของเครื่อง Ubiquiti loco m5 (กรณีเครื่องสามารถออก Internet ได้)

 การ Update Firmware ของเครื่อง Ubiquiti loco m5 (กรณีเครื่องสามารถออก Internet ได้)
ให้ทำเครื่อง Station ก่อน แล้วค่อยทำเครื่อง AP เพราะจะหลุดเพื่อเข้าไม่ได้
1. เข้า Menu SYSTEM ดู Version เก่า แล้วกด Check Now


2. ที่มุมขวาล่างถ้ามี Version ใหม่จะมีขึ้นมาให้กด Update

ถ้าเป็น Version ล่าสุดแล้วจะขึ้นเป็น Last Version

 
3. รอจนกว่าจะ Download เสร็จใช้เวลาไม่นาน



4. กด agree


5. กด Update อีกครั้ง

6. รอจนกว่าจะเสร็จระหว่างนั้นห้ามปิดเครื่อง

7. รอจนกว่าจะเสร็จแล้วเครื่องจะ Reboot

8. เมื่อเสร็จ Login อีกครั้ง ตัว Version ก็จะเปลี่ยนไป