outboxsystem.cs

来自「手机串口编程 手机串口编程 手机串口编程」· CS 代码 · 共 94 行

CS
94
字号
using System;

namespace JB.GraduateDesign.ESM.Business
{
	using JB.GraduateDesign.ESM.Entity;
	using JB.GraduateDesign.ESM.DataAccess;

	/// <summary>
	/// OutBoxSystem 的摘要说明。
	/// </summary>
	public class OutBoxSystem
	{
		public OutBoxSystem()
		{
			
		}

		public bool DeleteOutBox ( int[] outBoxIds )
		{

			for ( int i = 0; i < outBoxIds.Length; i ++ )
			{
				if ( outBoxIds[i] <= 0 )
				{
					throw new ApplicationException ( "参数错误,参数必须大于0" ); 
				}
			}

			OutBoxes outBoxes = new OutBoxes();
			try
			{
				return outBoxes.DeleteOutBox ( outBoxIds );

			}
			catch ( Exception e )
			{
				throw e;
			}
		}

		public OutBoxData GetSendedMessage ( int sendUserId )
		{
			if ( sendUserId <= 0 )
			{
				throw new ApplicationException ("参数错误。");
			}

			OutBoxes outBoxes = new OutBoxes();
			try
			{
				return outBoxes.SelectOutBox ( sendUserId, 0 );
			}
			catch ( Exception e )
			{
				throw e;
			}

		}

		public bool SendMessage ( OutBoxData data )
		{
			if ( data.OutBox.Count == 0 )
			{
				throw new ApplicationException ( "缺少要发送信息。" );
			}
			if ( data.OutBoxDetail.Count == 0 )
			{
				throw new ApplicationException ( "缺少接受信息的用户。" );
			}
			if ( data.OutBox.Count > 1 )
			{
				throw new ApplicationException ( "一次只能发送一条信息。" );
			}
			
			
			OutBoxes outBoxes = new OutBoxes();
			
			try
			{
				outBoxes.InsertOutBox ( data );
			}
			catch ( Exception e )
			{
				throw e;
			}
			finally
			{
				outBoxes.Dispose();
			}
			return true;
		}
	}
}

⌨️ 快捷键说明

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