⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcg21.htm

📁 Visual C++与数据库的连接经典实例
💻 HTM
📖 第 1 页 / 共 5 页
字号:

<BR>

<P>The receptionist fields incoming calls and attempts to connect the caller with the recipient. However, sometimes a caller can't be connected. In this case, the receptionist uses a custom Visual C++ application to create a special mail message that has specific information about the call.

<BR>

<P>The message is then sent to the recipient, who also is running this application. The application receives the mail and takes the message's contents and places the information about the call in a dialog box for the user. This user may then respond to the message when he or she returns. Although the recipient will probably call back the person who called originally, the message could be edited and forwarded to another person.

<BR>

<BR>

<A NAME="E68E108"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Creating Workflow Applications with Visual C++</B></FONT></CENTER></H3>

<BR>

<P>The primary use of mail-enabled Visual C++ database applications is to create workflow products. Workflow applications substitute e-mail routing methods for the conventional interoffice mail envelope to fill in forms and process documents. The objective of workflow applications is to eliminate the handling of paper documents. The database contains a primary record that identifies each document, plus related records that are used to route the document and to record the events that occur during the processing of the document.

<BR>

<P>Workflow products fall into three major classifications:

<BR>

<UL>

<LI><I>Electronic document interchange</I> <I>(EDI)</I>, which negates shuffling paper purchase orders, shipping notices, bills of lading, invoices, packing slips, and other documents involving the sale and shipment of tangible products. EDI originally was developed to automate transactions between auto makers and their suppliers. EDI forms are based on standard templates for a specific industry. Texas Instruments, Inc. is one of the few firms that provides standard EDI applications for Windows.

<BR>

<LI><I>Document-management systems</I> <I>(DMS)</I> that rely primarily on scanned images of incoming and intracompany paper documents. The primary users of document-management systems are insurance companies and financial services firms whose principal activities involve processing paper. Storing bitmapped images, even when they are compressed, occupies very large amounts of disk space, so image files often are stored on high-capacity multiple <I>write-once-read-many (WORM)</I> CD-ROM drives called <I>carousels</I>. WORM drives can contain from 640M to several gigabytes. The database maintains a record of the filename, the CD-ROM volume, and the CD-ROM drive on which the document is located for retrieval and archiving purposes. Keyfile Corp. and Reach Software Corp. are two of the major suppliers of large-scale, enterprise-wide document-management systems.

<BR>

<LI><I>Workgroup productivity applications</I> (groupware), such as Lotus Notes, are database-oriented products that apply to conventional text, word-processing, and worksheet files that are shared among members of workgroups or an entire firm. Lotus Notes also supports faxes and other bitmapped or vector images. The database is used to route the files and to record changes to the documents by members of the workgroup. One of the primary duties of the database is to maintain version control for the original document. Lotus currently relies on independent software vendors to provide enhancements to Notes, such as workflow and document-imaging capabilities, as well as integration with client-server RDBMSs.

<BR>

</UL>

<P>You can use Visual C++ to create specialized workflow applications that fall into any of these three categories. Only commercial workgroup productivity applications currently rely on e-mail systems for managing document routing. There is no fundamental reason, however, why customized EDI and DMS applications can't use e-mail methodology for document transmittal. The question is which e-mail methodology to use.

<BR>

<BR>

<A NAME="E69E263"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Looking to the Future of Workflow Applications</B></FONT></CENTER></H4>

<BR>

<P>Ordinarily in this book, discussions of the future of applications and programming tools follow the text that describes today's products. In this case, however, I reversed the order to provide perspective on the development of database-related MAAs and MEAs. The future of mail-aware and mail-enabled applications in the Microsoft environment has been projected in a number of review articles in the computer press. Forewarned is forearmed when it comes to profiting from the development of MAAs and MEAs based on Microsoft Mail, because Microsoft Mail currently is a moving target.

<BR>

<P>Microsoft's approach to competing with the highly successful Lotus Notes groupware application is to provide toolkits that let developers create their own MAAs. Windows 95 is extensively tuned to the concept of MAPI. Windows NT also is becoming MAPI-enabled. The next section discusses the (limited) applicability of the MAPI to Visual C++ database applications.

<BR>

<P>Windows 95 and the WIN32SDK offer a powerful punch in the MAPI arsenal. This toolkit will work both with Windows NT and with Windows 95, and it represents Microsoft's attempts to combine the Windows development platforms.

<BR>

<P>Enterprise Messaging Server (EMS) is a 32-bit Windows NT application that Microsoft demonstrated at the Microsoft Mail Users Conference in mid-1993. EMS is now called Exchange Server and is targeted for an early 1996 release. The server is an add-on to Windows NT Server, in the same vein as SNA Server and SQL Server for Windows NT Server. Exchange Server takes advantage of the international X.400 messaging standard instead of the Microsoft Mail protocol, and it also supports other standard network and messaging protocols such as TCP/IP, Simple and Extended MAPI, X.25, and X.500 directory-naming services. Exchange Server provides the Multipurpose Internet Mail Extensions (MIME) being developed by the Internet Management Group. The backbone of Exchange Server is an RDBMS for storing messages. Using an RDBMS rather than Microsoft Mail 3.5 or Notes' flat file structure lets users create joins and run queries against the database in order to manage messages and attached OLE objects.

<BR>

<P>Microsoft's challenge is to integrate these officially and unofficially announced products into a cohesive workflow-management development strategy to gain market share from Lotus Notes. The challenge facing Visual C++ database developers is to decide whether to wait for Exchange Server before investing the time required to learn the intricacies of Simple and Extended MAPI. Of course, Microsoft Exchange and Windows 95 became available to users in mid-1995, and a version of Windows NT with Exchange might be released in 1996.

<BR>

<BR>

<A NAME="E69E264"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Considering MAPI for Database Applications</B></FONT></CENTER></H4>

<BR>

<P>You can use the MAPI functions, MAPI Session, and MAPI Messages to create mail-enabled Visual C++ database applications.

<BR>

<UL>

<LI>MAPI Session provides logon services to establish a MAPI session and to close (log off) the session when the messaging operation is complete. Each MAPI session has an individual session handle that is similar in concept to the connection handle for an ODBC datasource (discussed in the preceding chapter). You can establish multiple MAPI sessions within a single application. The important thing to remember is to explicitly close each MAPI session your application opens.

<BR>

<LI>MAPI Messages provides all message-handling services for a MAPI session. An instance of MAPI Messages creates two buffers, <I>compose</I> and <I>read</I>, that contain the text and objects of messages you transmit and receive, respectively. The <I>compose buffer</I> contains only one message at a time. The <I>read buffer</I> contains an indexed array of messages, starting with an index of 0 for the first message.

<BR>

</UL>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>Generally, if you retain MFC's document-oriented structure, enabling MAPI support when you create your application will provide most of the mail support that most database decision tool applications will require.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>The MSDN CDs also include additional articles on MAPI, including &quot;Using Mail and MAPI[md]the Possibilities,&quot; an overview of the use of Mail in Executive Information Systems (EISs), and &quot;Creating Workgroup Solutions Using Microsoft Word, Microsoft Mail, and MAPI,&quot; which was presented by Michel Girard and Eric Wells at Tech*Ed. Both of these articles provide additional assistance in learning how to use the Mail APIs. &quot;Using Mail and MAPI&quot; makes a vague reference to combining MAPI and ODBC in EISs.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<P>Mail-aware and mail-enabled database applications rely on a fill-in-the-blanks approach to obtaining information to add to specified fields of database tables. You can develop a mail-aware Visual C++ application that generates messages based on choices made from combo boxes and text entered from text boxes, but you can't easily create applications that let the recipient modify the message with control objects. Parsing a completed message to update the database also is a complex process. The Microsoft Electronic Forms Designer add-in for Visual C++, discussed in the following section, provides a solution to these problems.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>TIP</B>

<BR>

<BR>To add MAPI to an existing MFC 4 application, follow these steps:</NOTE>

<BR>



<OL>

<LI>Using the Visual C++ resource editor, modify the application's File menu by adding a new command called Send Mail. Use the command identifier <U>ID_FILE_SEND_MAIL</U>. This identifier is defined in the AFXRES.H file.

<BR>

<LI>Add the following bold lines to your application's document message map. Be sure to add these lines outside of the <U>AFX_MSG_MAP</U> block:

<BR>



<PRE>

<FONT COLOR="#000080"><U>BEGIN_MESSAGE_MAP(CMailAwareDoc, CDocument)</U>

<U>    //{{AFX_MSG_MAP(CMailAwareDoc)</U>

<U>        // NOTE: ClassWizard will add and remove mapping macros here.</U>

<U>        // DO NOT EDIT what you see in these blocks of generated code!</U>

<U>    //}}AFX_MSG_MAP</U>

<B><U>    ON_COMMAND(ID_FILE_SEND_MAIL, OnFileSendMail)</U></B>

<B><U>    ON_UPDATE_COMMAND_UI(ID_FILE_SEND_MAIL, OnUpdateFileSendMail)</U></B>

<U>END_MESSAGE_MAP()</U></FONT></PRE>This technique works for both <U>CDocument</U>- and <U>COleDocument</U>-based applications.

<BR>

<LI>After making these changes, rebuild the project.

<BR>

</OL>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BR>

<A NAME="E69E265"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Creating a New MAPI-Compliant Application</B></FONT></CENTER></H4>

<BR>

<P>This section describes the Visual C++ AppWizard steps used to create a new application that supports MAPI. The changes that AppWizard makes to the application are slight; it follows the same steps described in the preceding section.

<BR>

<P>To create a MAPI-compatible application, start AppWizard. In the Step 4 of 6 dialog, select the MAPI (Messaging API) option, as shown in Figure 21.3.

<BR>

<P><B><A HREF="21vcg03.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/21vcg03.gif">Figure 21.3. Adding MAPI support in AppWizard's Step 4 of 6 dialog.</A></B>

<BR>

<P>After you've created your new project, it will have the necessary support for MAPI. The CD that comes with this book has an example of a Visual C++ 4 AppWizard-created MAPI program. Look in the CHAPTR21\Mail Aware folder.

<BR>

<BR>

<A NAME="E68E109"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Obtaining and Using the Schedule+ Libraries</B></FONT></CENTER></H3>

<BR>

<P>Schedule+ is a mini-PIM (personal information management) system that is included with Microsoft Mail 3+, Windows for Workgroups, and Windows NT. Schedule+ 7, included with Microsoft Office 95, incorporates an appointment calendar, a workgroup appointment management system, and a prioritized to-do (project and task) list. Figure 21.4 shows the to-do list window with three projects and a few prioritized tasks for each project. You can assign scheduled completion dates for each task and block time in your appointment calendar to complete the tasks. Figure 21.5 shows the planning window of Schedule+ with time blocked to complete some of the writing tasks for this book.

<BR>

<P><B><A HREF="21vcg04.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/21vcg04.gif">Figure 21.4. Schedule+'s project and task manager window.</A></B>

<BR>

<P><B><A HREF="21vcg05.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/21vcg05.gif">Figure 21.5. Schedule+'s Planner window with time blocked for task completion.</A></B>

<BR>

<P>The appointment management system uses Mail to arrange meetings with other members of a workgroup by comparing the participants' free and busy times. When you request a meeting for a specific date and time, Schedule+ creates a graphic overlay of all of the participants' schedules, including your own. If the time you choose conflicts with a participant's schedule, you can select another time or date. Schedule+ also lets you set up postoffice accounts for resources, such as meeting rooms and equipment. Thus, you also can take into account the availability of the resources you need for the meeting. Figure 21.6 shows the dialog box that you use to request a meeting with other members of your workgroup. Users can respond that they will, won't, or might attend the meeting.

<BR>

<P><B><A HREF="21vcg06.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/21vcg06.gif">Figure 21.6. The dialog box that is used to set up a workgroup meeting.</A></B>

<BR>

<BR>

<A NAME="E69E266"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>The Schedule+ Libraries for C</B></FONT></CENTER></H4>

<BR>

<P>The Schedule+ Libraries for C consist of SPLUS.DLL, which contains the functions to manipulate Schedule+ data, documentation for declaring and calling the functions in both Visual C++ and C, and a sample Visual C++ and C application with source code. The Schedule+ Libraries are available for downloading as SAL.ZIP from Library 15, MS Schedule+, of the MSWRKGRP forum on CompuServe and is also included on the MSDN Level I CDs. The Visual C++ documentation is contained in SPLUS-C.DOC, a Word for Windows file. The current version of the Schedule Libraries is 1.0a2.

<BR>

<P><B>WARNING</B>

<BR>

<BR>The Schedule+ Libraries are available only in a 16-bit version. At the time this book was written, Microsoft hadn't announced a 32-bit version.

<P>The functions contained in SPLUS.DLL fall into the following two categories:

<BR>

<UL>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -