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

📄 voicecmd.asmx.cs

📁 2001年度.net程序大赛清华大学作品 网上订票系统
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Threading;
using System.Runtime.InteropServices;
using SpeechExt;
using System.Web.SessionState;
using GateWay.com.test.ticket;

namespace GateWay
{

	public struct CmdResult
	{
		public string userid;
		public string destination;
		public string time;
		public int method;
		public int count;
		public string text;
	}
	
	
	/// <summary>
	/// Summary description for VoiceCmd.
	/// </summary>
	public class VoiceCmd : System.Web.Services.WebService
	{

		public VoiceCmd()
		{
			//CODEGEN: This call is required by the ASP.NET Web Services Designer
			InitializeComponent();
		}

		#region Component Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
		}
		#endregion

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
		}

		// WEB SERVICE EXAMPLE
		// The HelloWorld() example service returns the string Hello World
		// To build, uncomment the following lines then save and build the project
		// To test this web service, press F5


		[WebMethod(true)]
		public CmdResult Command(string userid , byte[] voice)
		{
			if (Session["destination"] == null)
                Session["destination"] = null;
			if (Session["time"] == null)
				Session["time"] = null;
			if (Session["method"] == null)
                Session["method"] = -1;
			if (Session["count"] == null)
				Session["count"] = 0;

			string strInfo="";

			SpeechExt.Speech speech = new SpeechExt.Speech( );
			SpeechExt.CmdInfo cmdInfo = speech.VoiceToCommand( voice );

			CmdResult cmdResult = new CmdResult();
			cmdResult.userid = userid;

			if( cmdInfo.bSuccess )
			
			{
				if( (cmdInfo.destination != null) && ((string)Session["destination"] == null) )
					Session["destination"] =cmdInfo.destination;

				if( (cmdInfo.time != null) && ((string)Session["time"] == null) )
					Session["time"] =cmdInfo.time;

				if( (cmdInfo.method != -1) && ((int)Session["method"] == -1) )
					Session["method"]=cmdInfo.method;
	
				if( (cmdInfo.count != 0) && ((int)Session["count"] == 0 ))
					Session["count"] =cmdInfo.count;
					
				if( ((int)Session["count"]!=0) && ((int)Session["method"]!=-1) && (Session["time"]!=null) &&(Session["destination"]!=null))
				{
					cmdResult.destination =(string) Session["destination"];;
					cmdResult.time = (string)Session["time"];
					cmdResult.method = (int)Session["method"] ;
					cmdResult.count = (int)Session["count"] ;

					GateWay.com.test.ticket.OrderContent orderContent = new OrderContent();
					
					orderContent.iCount = cmdResult.count;
					orderContent.szDestination = cmdResult.destination;
					orderContent.iMethod = cmdResult.method;
					orderContent.szTime = cmdResult.time;
					orderContent.szUserID = userid ;
					GateWay.com.test.ticket.Service service = new GateWay.com.test.ticket.Service();
					int result = service.Order(orderContent);
					switch(result)
					{
						case 1:
							strInfo +="\nyou have got what you want ,thank you";
							break;
						case -1:
							strInfo +="\nillegal user";
							break;
						case -2:
							strInfo +="\nillegal account";
							break;
						case -3:
							strInfo +="\nchange your schedule please";
							break;
						case -4:
							strInfo += "\nthe tickets are sold out";
							break;
						case -5:
							strInfo += "\nyou have not enough money";
							break;
					}					
					Session["destination"] = null;
					Session["time"] = null;
					Session["method"] = -1;
					Session["count"] = 0;
				}
				else
				{
					strInfo +="please tell me	";
					if( (int)Session["count"] ==0 )
						strInfo +="the ticket number ";

					if( (string)Session["destination"] == null )
						strInfo +="the destination ";

					if( (string)Session["time"] == null )
						strInfo +="the schedule time ";

					if( (int)Session["method"] == -1 )
						strInfo +="the travel method ";
				}
				cmdResult.text = strInfo;
				
			}						//end of if 
			else
			{
				cmdResult.text = "pardon please";
			}

			return cmdResult;
		}

	}
}

⌨️ 快捷键说明

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