Xây dựng chương trình bĩc ảnh theochuẩn XML

Một phần của tài liệu (LUẬN văn THẠC sĩ) xây dựng ứng dụng trao đổi dữ liệu đa phương tiện theo chuẩn NewsML g2 ứng dụng tại thông tấn xã việt nam 04 (Trang 41)

4.2. Xây dựng chương trình

4.2.1. Xây dựng chương trình bĩc ảnh theochuẩn XML

- Chương trình sử dụng ngơn ngữ vb.net của bộ visual studio 2010.

- Đầu vào của chương trình: Ảnh định dạng NEWSML G2 bao gồm ảnh *.jpg với file định dạng XML lưu các thơng tin của ảnh

- Đầu ra của chương trình: Ảnh lưu thư mục F:\ImgStore\yyyy\MM\dd (server Photo), thơng tin của ảnh lưu vào database Photostore. Các biên tập viên dùng chương trình biên tập ảnh để xem, biên tập nội dung trong phần ảnh nhập.

 Chương trình đọc thơng tin ảnh theo chuẩn XLM gồm các thơng tin:

Datecreated, Imgcredit, Photographer,

CountryName,City_province,Title,Caption,CapWriter lưu vào class

 Chương trình ftp ảnh lên máy chủ để lưu trữ. Ảnh được lưu tại thư mục F:\ImgStore\yyyy\MM\dd.

 Các thơng tin ảnh sẽ insert vào cơ sở dữ liệu Photostore

 Ảnh sau khi được ftp, insert thơng tin thanh cơng sẽ xĩa đi tránh tình trạng bĩc lại ảnh.

 Ảnh khơng ftp được hoặc khơng insert được vào cơ sở dữ liệu sẽ được chuyển sang thư mục khác.

Thực nghiệm:

Trong quá trình thử nghiệm, tơi đã tiến hành lấy ảnh theo chuẩn NEWSML G2 của hãng KYODO.

Đầu vào: Ảnh theo chuẩn NEWSML G2 lưu thu mục chứa ảnh của hãng KYODO Đầu ra: Là ảnh đã được lưu trong server Photostore cả file ảnh và thơng tin ảnh

Hình 4.1: Chương trình Photo_NEWSML-G2.

- Ảnh nhập vào trong hệ thống, chương trình Biên tập ảnh hiện các thơng tin ảnh cho biên tập viên.

Hình 4.2: Thơng tin ảnh theo chuẩn NEWSML G2. 4.2.2. Xây dựng chương trình phát ảnh theo chuẩn XML

- Đầu vào của chương trình: Danh sách ảnh được phát cho khách hàng lưu trong bảng Despatches trong database.

- Đầu ra của chương trình: Ảnh được gửi đến khách hàng theo chuẩn NEWSML G2 qua đường ftp.

- Quy trình xử lý của chương trình:

 Chương trình xác định ảnh phát cho khách hàng qua bảng Despatches

 Ảnh được phát sẽ ghi vàotheo chuẩn NewsML G2, gồm 1 file ảnh *.jpg và file XML.

 Ảnh được ftp tới khách hàng

 Trong trường hợp lỗi ảnh sẽ lưu lại vào thư mục khác Thực nghiệm:

- Trong quá trình thử nghiệm, tơi đã tiến hành test lấy ảnh gửi cho hãng KYODO.

- Đầu vào: Ảnh phát cho hãng KYODO. - Đầu ra: Ảnh gửi đi theo chuẩn NEWSML G2

Hình 4.3: Chương trình phát ảnh Despatches NEWSML-G2 - Nội dung file XML ghi theo cấu trúc của chuẩn NEWSML G2: - Nội dung file XML ghi theo cấu trúc của chuẩn NEWSML G2: <?xml version="1.0" encoding="utf-8" standalone="yes" ?>

-<NewsItem guid="tag:gettyimages.com,2010:GYI0062134533"

Version="3"Standard="NewsML-G2"Standardversion="2.15" xml:lang="en-US"> <CatalogRefhref="http://www.iptc.org/std/catalog/catalog.IPTC-G2-

Standards_22.xml" />

<CatalogRefhref="http://cv.gettyimages.com/nml2catalog4customers-1.xml" /> <RightsInfo>Vietnam News Agency</RightsInfo>

<Rights>Copyright 2014 The Vietnam News Agency. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.</Rights> -<ItemMeta>

<itemClassqcode="ninat:picture" />

<Provider>Vietnam News Agency</Provider> <VersionCreated>4/30/2014</VersionCreated> <PubStatusqcode="stat:usable" /> </ItemMeta> -<ContentMeta> <ContentCreated>9/29/2014 11:15:01 AM</ContentCreated> <Creator>Tran Le Lam</Creator> <Contributor>111</Contributor> <Category>NCNG</Category> <Creditline>Images</Creditline> <Subject>Khong co gi</Subject> <Country>Việt Nam</Country>

<City>Đà Nẵng</City> <Provice/>

<Keyword/>

<Urgency>2</Urgency>

<Headline>Beach tourism season launched in Da Nang</Headline>

<Description>[29/09/2014 11:12:00] [01/05/2014 17:56:58] Han 11 May 1- A festival entitled “Danang beach - old destination, new look” was launched at Bien Dong park and the Pham Van Dong beach in the central city of Da Nang on April 30. The six-day festival is featuring a wide and highly entertaining range of

cultural activities including “Bai Choi” (singing while acting as playing cards), folk games, photo exhibitions and art performances. This year’s event will introduce a few new exciting and exotic activities such as bikini flash mob performance, beach volleyball, hip hop dance competition, and bike and kayak racing, for all to enjoy. Photo: Children release doves into the air during the opening ceremony. VNA Photo: Trần Lê Lâm.</Description>

</ContentMeta> -<ContentSet>

<RemoteContenthref="1964605.jpg" Version="1" Size="108KB" Width="1062" Contenttype="image/jpeg" Height="694" /> <altId>1964605</altId> </ContentSet> </NewsItem> 4.2.3. Xây dựng dịch vụ web a. Mơ hình hệ thống Hình 4.4: Web TTXVN_Biên tập Ảnh

- Hệ thống nghiên cứu xây dựng gồm: máy chủ database lưu trữ cơ sở dữ liệu. Máy chủ dịch vụ web sẵn sang đợi lệnh khi cĩ dịch vụ web gọi tới. Máy khách sẽ gọi các yêu cầu cần thực hiện

b. Xây dựng dịch vụ web

- Ngơn ngứ lập trình: vb.net của bộ visual studio 2010. - Tạo dịch vụ web:

Hình 4.5: Solution dịch vụ web

 Bước 1: Khởi động Víual Studio.net tạo project mới sử dụng ASP.net Web application.

 Bước 2: Trong Solution Explorer, đổi tên tập tin Services1.amx thành WSVBIENTAPANH.asmx, và đổi tên lớp Services1 thành WSV BIEN TAP ANH

 Bước 3: khai báo trong web.config kết nối đến cơ sở dữ liệu <addname="connection"connectionString="Server=MINHNK- PC\MINHNK;Database=PhotoStore;uid=nvla1;pwd=Guiduyet1;" />

 Bước4: Hồn thiện các webMethod bao gồm Cập nhật, chỉnh sửa, tìm kiếm thơng tin ảnh đĩng gĩi thơng tin.

 Bước 5: Xây dựng site TTXVN_Bientapanh trỏ vào dịch vụ web

Hình 4.6: Web TTXVN_Biên tập ảnh.

Dịch vụ web bao gồm các chức năng: Update_image, Insert_image, Update_Despatches, Insert_Despatches, Insert_UserRight, UserRight, Get_IMG.

Hình 4.7: Các dịch vụ web. c. Ứng dụng biên tập ảnh

- Ngơn ngứ lập trình: vb.net của bộ visual studio 2010.

Tạo ứng dụng form Chương trình Biên tập ảnh để gọi đến dịch vụ web Máy khách gọi dịch vụ web bằng cách dùng chức năng add web reference

Hình 4.8: Giao diện hộp thoại add web reference. - Kết quả thực nghiệm:

 Đầu vào: chương trình biên tập ảnh gọi đến dịch vụ web.

 Đầu ra: dịch vụ Web trả về kết quả cho chương trình biên tập ảnh - Các kết quả thực hiện trong luận văn:

 Kết quả trả trả về thơng tin Nhĩm truy cập, tên truy cập của dịch vụ web

Hinh 4.9: Giao diện đăng nhập  Kết quả trả về pass word đăng nhập thành cơng.  Kết quả trả về pass word đăng nhập thành cơng.

Hình 4.10: Giao diện đăng nhập thành cơng.  Kết quả tra cứu ảnh.  Kết quả tra cứu ảnh.

4.3. Kết luận và hướng phát triển Kết quả đạt được: Kết quả đạt được:

- Sau thời gian tìm hiểu và được sự hướng dẫn tận tình, luận văn của tơi đã đạt được một số kết quả bước đầu như sau:

- Luận văn đã tìm hiểu khái quát về Hệ thống Ảnh của thơng tấn xã Việt Nam  Luận Văn trình bày trình bày chi tiết về Chuẩn NEWSML-G2, lich sử phát triển, cấu trúc của chuẩn NEWML G2 text, Picture và video.

 Nghiên cứu ứng dụng web dich vụ web, cấu trúc, cách thức hoạt động.

 Giải quyết việc Xây dựng ứng dụng trao đổi dữ liệu đa phương tiện theo chuẩn NewsML G2 ứng dụng tại Thơng tấn xã Việt Nam, xây dựng dịch vụ web để phục vụ cho yêu cầu nâng cấp chương trình biên tập ảnh

Hạn chế:

- Hiện tại các dich vụ web vẫn chưa được hồn thành hết, vẫn cịn nhiều dịch vụ cần hồn thiện để đáp ứng với yêu cầu của người dung.

Hướng phát triển:

- Trong thời gian tới, Tơi sẽ tiếp tục phát triển các vấn đề nghiên cứu của luận văn là:Hồn thiện dịch vụ web để đáp ứng được yêu cầu và phục vụ cho yêu cầu nâng cấp chương trình biên tập ảnh.

TÀI LIỆU THAM KHẢO Tiếng Việt:

1. ThS. Nguyễn Minh Đạo,GIÁO TRÌNH LẬP TRÌNH WEB VỚI ASP.NET,

NXB Đại học Quốc gia TP.Hồ Chí Minh.

2. VietNamNet ICOM JSC (2009), "Tài liệu vận hành hệ thống SMS Thơng Tấn Xã Việt Nam".

3. Nguyễn Phương Lan, 2005, XML nền tảng và ứng dụng, NXB Lao động xã hội.

Tiếng Anh:

4. Aaron E Walsh, 2002, UDDI, SOAP, and WSDL: The Web Services

Specification Reference Book Paperback, Pearson Education.

5. Bill Evjen, Kent Sharkey, Thiru Thangarathinam, 2007, Professional XML,

Wrox.

6. David Duke, Lynda Hardman, Alexander G.Hauptmann, 2008, Semantic Multimedia, Springer.

7. David Hunter, Kurt, 2003, Beginning XML, 2nd Edition: XML Schemas, SOAP, XSLT, DOM, and SAX 2.0. Wiley Publishing, inc.

8. Ethan Cerami, 28 Feb 2002, Web Services Essentials Paperback – Import, O'Reilly Media.

9. G. Alonso, F. Casati, H. Kuno, V. Machiraju ,2004, Web Services: Concepts, Architecture and Applications, Springer Verlag

10. International Press Telecommunications Council, 2014, NewsML-G2 Implementation Guide.

11. James Snell,Doug Tidwell, 2001, Programming Web Services with SOAP,

O'Reilly & Associates, Inc. Sebastopol, CA, USA

12. Lyndon Nixon, Stamatia Dasiopoulou, Multimedia, Broadcasting, and eCulture,Springer Berlin Heidelberg

13. Randy J. Ray, Pavel Kulchenko, Dec 19, 2002, Programming Web Services

with Perl, O'Reilly Media.

14. Raphặl Troncy,2008, Bringing the IPTC News Architecture into the Semantic Web, Conference Paper Amsterdam

15. Rod Stephens Brian Hochgurtel,2002,Visual Basic .NET and XML,Wiley 16. Roger Jennings, 2002, Visual Basic.NET XML Web Services Developer's

Guide, McGraw-Hill Professional.

17. Susan F. Marseken,2010, Newsml,Betascript Publishing

18. Scott Mitchell, 2004, An Extensive Examination of Web Services, U.S. and

Canada.

19. Vikram Ramchand, Sonal Mukhi, 2008, XML WebServices and SOAP ,Bpb

Publications.

20. Sandeep Chatterjee, 2003, Developing Enterprise Web Services: An Architect's Guide Paperback, Prentice Hall.

Địa chỉ web: 21. http://iptc.cms.apa.at/site/News_Exchange_Formats/ 22. https://iptc.org/standards/newsml-g2/ 23. http://www.afp.com/fr/professionnels/services/iris/newsmlg2-documentation/ 24. http://www.w3.org/TR/sw-oosd-primer/ 25. http://www.codeproject.com/ 26. http://tutorials.jenkov.com/web-services/index.html

PHỤ LỤC 1.Mã nguồn đọc thơng tin ảnh XLM

PublicFunction getinfo_XML (ByVal File AsString, ByRef imgInfo AssystemInfo) AsBoolean

Try

Dim xmldoc AsNewXmlDocument () Dim xmlnode AsXmlNodeList

Dim m_node AsXmlNode

xmldoc.Load (File)

rsAcess_Xml = New ADODB.Recordset

rsAcess_Xml.Open (sAcess_Xml, dbConnect, 1, 2) For k = 0 To rsAcess_Xml.RecordCount - 1 Element = "" ChildElement = "" Attribute = "" Get_ChildElement = "" Get_Attribute = ""

Element = rsAcess_Xml.Fields("Element").Value

ChildElement = rsAcess_Xml.Fields("ChildElement").Value Des = rsAcess_Xml.Fields("Des").Value

Try

Count_Ele = rsAcess_Xml.Fields("count_Ele").Value Catch ex AsException

Count_Ele = 0 EndTry

Try

Attribute = rsAcess_Xml.Fields("Attribute").Value Catch ex AsException

Attribute = ""

EndTry

Dim tmp_ele AsInteger tmp_ele = 0

xmlnode = xmldoc.GetElementsByTagName(Element) ForEach m_node In xmlnode

If Attribute = ""Then

Get_ChildElement =

m_node.SelectSingleNode(ChildElement).InnerText Else

If tmp_ele = Count_Ele Then Try

Get_Attribute = m_node.Attributes(Attribute).Value Exit For Catch ex AsException Get_Attribute = "" EndTry Else tmp_ele = tmp_ele + 1 EndIf EndIf Next SelectCase Des Case"Datecreated" If Get_Attribute = ""Then imgInfo.Datecreated = Get_ChildElement Else imgInfo.Datecreated = Get_Attribute EndIf Case"City_province" If Get_Attribute = ""Then imgInfo.City_province = Get_ChildElement Else imgInfo.City_province = Get_Attribute EndIf Case"Title" If Get_Attribute = ""Then imgInfo.Title = Get_ChildElement Else imgInfo.Title = Get_Attribute EndIf Case"Caption" If Get_Attribute = ""Then imgInfo.Caption = Get_ChildElement Else imgInfo.Caption = Get_Attribute EndIf Case"Img1" If Get_Attribute = ""Then imgInfo.img1 = Get_ChildElement Else imgInfo.img1 = Get_Attribute

EndIf Case"Img2" If Get_Attribute = ""Then imgInfo.img2 = Get_ChildElement Else imgInfo.img2 = Get_Attribute EndIf Case"Img3" If Get_Attribute = ""Then imgInfo.img3 = Get_ChildElement Else imgInfo.img3 = Get_Attribute EndIf EndSelect rsAcess_Xml.MoveNext() Next rsAcess_Xml.Close() Catch ex AsException getinfo_XML = False EndTry getinfo_XML = True EndFunction

2. Mã nguồn ghi thơng tin ảnh ra XML.

Dim xml_text_writer AsNewXmlTextWriter(sFileTam, System.Text.Encoding.UTF8) xml_text_writer.WriteStartDocument(True) xml_text_writer.Formatting = Formatting.Indented xml_text_writer.Indentation = 2 xml_text_writer.WriteStartElement("NewsItem") xml_text_writer.WriteAttributeString("guid", "tag:gettyimages.com,2010:GYI0062134533") xml_text_writer.WriteAttributeString("Version", "3") xml_text_writer.WriteAttributeString("Standard", "NewsML-G2") xml_text_writer.WriteAttributeString("Standardversion", "2.15") xml_text_writer.WriteAttributeString("xml:lang", "en-US") xml_text_writer.WriteStartElement("CatalogRef") xml_text_writer.WriteAttributeString("href", "http://www.iptc.org/std/catalog/catalog.IPTC-G2-Standards_22.xml") xml_text_writer.WriteEndElement() xml_text_writer.WriteStartElement("CatalogRef")

xml_text_writer.WriteAttributeString("href",

"http://cv.gettyimages.com/nml2catalog4customers-1.xml") xml_text_writer.WriteEndElement()

xml_text_writer.WriteElementString("RightsInfo", "Vietnam News Agency") xml_text_writer.WriteElementString("Rights", IPTCTemp1.Rights)

xml_text_writer.WriteStartElement("ItemMeta") xml_text_writer.WriteStartElement("itemClass")

xml_text_writer.WriteAttributeString("qcode", "ninat:picture") xml_text_writer.WriteEndElement()

xml_text_writer.WriteElementString("Provider", "Vietnam News Agency") xml_text_writer.WriteElementString("VersionCreated", IPTCTemp1.DateCreated) xml_text_writer.WriteStartElement("PubStatus") xml_text_writer.WriteAttributeString("qcode", "stat:usable") xml_text_writer.WriteEndElement() xml_text_writer.WriteEndElement() xml_text_writer.WriteStartElement("ContentMeta") xml_text_writer.WriteElementString("ContentCreated", IPTCTemp1.contentCreated) xml_text_writer.WriteElementString("Creator", IPTCTemp1.creator) xml_text_writer.WriteElementString("Contributor", IPTCTemp1.contributor) xml_text_writer.WriteElementString("Category", IPTCTemp1.category) xml_text_writer.WriteElementString("Creditline", "Images") xml_text_writer.WriteElementString("Subject", IPTCTemp1.Subject) xml_text_writer.WriteElementString("Country", IPTCTemp1.country) xml_text_writer.WriteElementString("City", IPTCTemp1.city) xml_text_writer.WriteElementString("Provice", IPTCTemp1.provice) xml_text_writer.WriteElementString("Keyword", IPTCTemp1.keyword) xml_text_writer.WriteElementString("Urgency", IPTCTemp1.urgency) xml_text_writer.WriteElementString("Headline", IPTCTemp1.headline) xml_text_writer.WriteElementString("Description", IPTCTemp1.description) xml_text_writer.WriteEndElement() xml_text_writer.WriteStartElement("ContentSet") xml_text_writer.WriteStartElement("RemoteContent")

xml_text_writer.WriteAttributeString("href", " " & IPTCTemp1.href & "") xml_text_writer.WriteAttributeString("Version", " 1")

xml_text_writer.WriteAttributeString("Size", " " & IPTCTemp1.size & "") xml_text_writer.WriteAttributeString("Width", " " & IPTCTemp1.width & "") xml_text_writer.WriteAttributeString("Contenttype", " image/jpeg")

xml_text_writer.WriteAttributeString("Height", " " & IPTCTemp1.height & "") xml_text_writer.WriteEndElement() xml_text_writer.WriteElementString("altId", IPTCTemp1.altId) xml_text_writer.WriteEndElement() xml_text_writer.WriteEndElement() xml_text_writer.Close()

Một phần của tài liệu (LUẬN văn THẠC sĩ) xây dựng ứng dụng trao đổi dữ liệu đa phương tiện theo chuẩn NewsML g2 ứng dụng tại thông tấn xã việt nam 04 (Trang 41)

Tải bản đầy đủ (PDF)

(58 trang)