1 The Warehouse Program. 2 A console program. Listens for connect requests from the call center program. Accepts connection. Reads message. Order ID Prints.

Slides:



Advertisements
Similar presentations
1 Northwind Traders Order Entry. 2 Northwind Traders Call Center Add an Order Entry capability to the Northwind Traders Call Center application. Start.
Advertisements

1 Derived Classes and Inheritance Chapter Objectives You will be able to: Create derived classes in C#. Understand polymorphism. Write polymorphic.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
Distributed Systems Tutorial 1 - Getting Started with Visual C#.NET.
MS.Net Framework with emphasis on online gaming Ed Mucker CS522 9 Dec 02.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
1 Web Services Visual C# 2008 Step by Step Chapter 30.
 2002 Prentice Hall. All rights reserved. 1 Chapter 22 – Networking: Streams- Based Sockets and Datagrams Outline 22.1 Introduction 22.2 Establishing.
Internet Protocols & Client Server Programming
11 Values and References Chapter Objectives You will be able to: Describe and compare value types and reference types. Write programs that use variables.
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
Network Layer Programing Connection-Oriented Sockets SWE 344 Internet Protocols & Client Server Programming.
JavaScript & jQuery the missing manual Chapter 11
Introduction to Classes SWE 344 Internet Protocols & Client Server Programming.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Libsecondlife: Bots Hyungwook Park. LSL vs. libsecondlife Linden Script Language (LSL)  Programming language used by residents of Second Life  Controls.
Lector: Aliyev H.U. Lecture №5 Telecommunication network software design with.NET. Using streams for network programming TASHKENT UNIVERSITY OF INFORMATION.
Copyright © 2006 Thomas P. Skinner1 Chapter 5 Indexers, Interfaces, and Enumerators.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Windows Programming Using C# Internet Programming.
Session 08: Architecture Controllers or Managers Graphical User Interface (GUI) FEN AK - IT Softwarekonstruktion.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
1 Introduction to C# Programming Console applications No visual components Only text output Two types MS-DOS prompt - Used in Windows 95/98/ME Command.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
Chapter 9 1 Chapter 9 – Part 1 l Overview of Streams and File I/O l Text File I/O l Binary File I/O l File Objects and File Names Streams and File I/O.
Sample Application Multi Layered Architecture (n-tier): –Graphical User Interface (GUI): Forms, components, controls The Visual Designer in Visual Studio.
Lector: Aliyev H.U. Lecture №11: FTP based file communication software design. Communicating with File Servers TASHKENT UNIVERSITY OF INFORMATION TECHNOLOGIES.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Multi-Client/Server GUI Application. Overview As part of the TCP.
1 Week 12 l Overview of Streams and File I/O l Text File I/O Streams and File I/O.
1 Project 7: Northwind Traders Order Entry. 2 Northwind Order Entry Extend the Select Customer program from Project 6 to permit the user to enter orders.
An Example of Windows Forms Applications Windows-based application –Win Forms Control structures (selection and repetition) Graphics Read integers from.
CS590VC – Tutorial 6 Client-side connection through external application.
Java Classes. Consider this simplistic class public class ProjInfo {ProjInfo() {System.out.println("This program computes factorial of number"); System.out.println("passed.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 22.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
Connectionless Sockets SWE 344 Internet Protocols & Client Server Programming.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
1 Introduction to C# Programming Console applications No visual components Only text output Two types MS-DOS prompt - Used in Windows 95/98/ME Command.
Li Tak Sing COMPS311F. RMI callbacks In previous example, only the client can initiate a communication with the server. The server can only response to.
12/5/2015.net 1 system.net Contains any network functionallity you would need in c# Several sub namespaces exists to allow for more fined control –System.Net.Sockets.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
1 Avoiding Hacker Attacks. 2 Objectives You will be able to Avoid certain hacker attacks and crashes due to bad inputs from users.
1 Tips & Tricks: Using System.Net To Write Better Connected Applications Durgaprasad Gorti COML02 Test Lead Microsoft Corporation.
Text Files and String Processing
Networking OSI (Open Systems Interconnection) model of computer networking, seven layers (the Application, Presentation, Session, Transport, Network, Data.
Architecture Multi Layered Architecture (n-tier): Application: Model Controllers Database Access Graphical User Interface (GUI): Forms, components, controls.
Adviser Panel. Go to All DD Track Advisers: Click “Advisor Login”
1 Low Level ADO.NET Operations II Microsoft Visual C# 2008 Step by Step Chapter 25.
Exception Handling SWE 344 Internet Protocols & Client Server Programming.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Java API for distributed computing.
Strings in C++/CLI us/library/system.string.aspxhttp://msdn.microsoft.com/en- us/library/system.string.aspx public: static.
1 Handling Errors and Exceptions Chapter 6. 2 Objectives You will be able to: 1. Use the try, catch, and finally statements to handle exceptions. 2. Raise.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 14 th Lecture Pavel Ježek
How to develop a VoIP softphone in C# that enables SIP Instant Messaging (IM) This presentation describes how to create a softphone in C# that allows you.
How to develop a VoIP softphone in C# by using OZEKI VoIP SIP SDK This presentation demonstrates the first steps concerning to how to develop a fully-functional.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
1 Adding a Model. We have created an MVC web app project Added a controller class. Added a view class. Next we will add some classes for managing movies.
Echo Networking COMP
Programming in visual basic .net Visual Basic Building Blocks
Looking at our “Getting Started” application
Computing with C# and the .NET Framework
Getting Started with Programming
Advanced Programming Lecture 02: Introduction to C# Apps
Exception Handling CSCI293 - C# October 3, 2005.
Constructors, GUI’s(Using Swing) and ActionListner
Chapter 13 Exception Handling: A Deeper Look
Presentation transcript:

1 The Warehouse Program

2 A console program. Listens for connect requests from the call center program. Accepts connection. Reads message. Order ID Prints picklist Instructions for a packer. Similar to invoice, but no prices.

3 Getting Started Create a new C# Console Application. Northwind_Warehouse Start by getting username and password for database connection string. Don’t show password on the screen! Note: No namespace declarations.

4 Get_Connection_Info using System; using System.Text; class Program { public static string Username; public static string Password; static void Get_Connection_Info() { Console.Write("User name: "); Username = Console.ReadLine(); Console.Write("Password:"); ConsoleColor saved_color = Console.ForegroundColor; Console.ForegroundColor = Console.BackgroundColor; Password = Console.ReadLine(); Console.ForegroundColor = saved_color; }

5 Get_Connection_Info static void Main(string[] args) { Console.WriteLine("Northwind Traders Warehouse Program starting\n"); Get_Connection_Info(); Console.WriteLine(); Console.WriteLine(Username + " " + Password); Console.ReadLine(); }

6 Signing In

7 Process Network Messages Code copied from TCP Echo Server with some modifications Downloads/2011_04_28_Northwind_Warehouse/Process_Network_ Messages.cs Downloads/2011_04_28_Northwind_Warehouse/Process_Network_ Messages.cs Add usings: using System.Net; using System.Net.Sockets; Convert main() into Process_Network_Messages()

8 Process_Network_Messages static string Process_Network_Messages() { String Order_ID = ""; const int BUFSIZE = 32; int servPort = 7; TcpListener listener = null; try { listener = new TcpListener(IPAddress.Any, servPort); listener.Start(); } catch (SocketException se) { Console.WriteLine(se.ErrorCode + ": " + se.Message); Console.ReadLine(); Environment.Exit(se.ErrorCode); }

9 Process_Network_Messages byte[] rcvBuffer = new byte[BUFSIZE]; int bytesRcvd; TcpClient client = null; NetworkStream netStream = null; while (true) { Console.WriteLine("Waiting for orders\n"); Order_ID = ""; try { client = listener.AcceptTcpClient(); netStream = client.GetStream(); bytesRcvd = netStream.Read(rcvBuffer, 0, rcvBuffer.Length); while (bytesRcvd > 0) { Order_ID += Encoding.ASCII.GetString(rcvBuffer, 0, bytesRcvd); bytesRcvd = netStream.Read(rcvBuffer, 0, rcvBuffer.Length); } netStream.Close(); client.Close(); }

10 Process_Network_Messages catch (Exception e) { Console.WriteLine(e.Message); if (netStream != null) { netStream.Close(); } Console.ReadLine(); } print_picklist(Order_ID); }

11 print_picklist() Stub static void print_picklist(string order_id) { Console.WriteLine("Order ID: " + order_id); }

12 Program.cs static void Main(string[] args) { Console.WriteLine("Northwind Traders Warehouse Program starting\n"); Get_Connection_Info(); Console.WriteLine(); //Console.WriteLine(Username + " " + Password); Process_Network_Messages(); Console.ReadLine(); } Build and run.

13 Client Program Modify Call Center program to send a message to the warehouse whenever a new order is added to the database Just send Order IDs. TCP Echo Client code modified for this purpose. Downloads/2011_04_28_Northwind_Warehouse Downloads/2011_04_28_Northwind_Warehouse File Network_IO.cs

14 Network_IO.cs using System; using System.Text; using System.IO; using System.Net.Sockets; static public class Network_IO { static public void Notify_Warehouse(int Order_ID) { string server = " "; byte[] byteBuffer; int servPort = 7; TcpClient client = null; NetworkStream netStream = null;

15 Network_IO.cs string msg = Order_ID.ToString(); byteBuffer = Encoding.ASCII.GetBytes(msg); try { client = new TcpClient(server, servPort); netStream = client.GetStream(); netStream.Write(byteBuffer, 0, byteBuffer.Length); } catch (Exception e) { Console.WriteLine("Error sending message to warehouse\n"); Console.WriteLine(e.Message); } finally { if (netStream != null) { netStream.Close(); } if (client != null) { client.Close(); }

16 Order_Entry_Form.cs Add to Submit Order event handler After writing Order Details to the database Network_IO.Notify_Warehouse(order.OrderId);

17 Call Center Communicating with Warehouse

18 What else? We need the entity classes from the Call Center program in the warehouse program: Order Order_Detail Product Database_Class Customer Customer_DB Some must be modified to get their information from the database rather than just writing to the database.

19 What else? Class Picklist Gets order info for a specified Order ID Using the entity classes Prints the picklist Modified version of code from Project 8 that prints invoices. Download complete program: File Warehouse.zip

20 Observations We are using a console application to do stuff that is normally done only in Windows forms applications. Note declaration of PrintDocument Picklist.cs line 19 Normally in generated code. Initialization code to instantiate the PrintDocument and hook up the event handler. Picklist.cs lines (In Constructor) Normally done by generated code, the InitializeComponent() method called from the Form constructor.

21 Observations PrintPage event handler had to be manually entered into the source file. Couldn't double click on an icon and get Visual Studio to set it up automatically. Had to manually add some references to the project: System.Drawing System.Windows.Forms Visual Studio doesn't expect these to be used in a Console application.

22 Warehouse Program Build and run

23 Call Center Communicating with Warehouse

24 A Picklist End of Presentation