最近公司的项目比较忙所以没及时更新第二篇.不要骂我是贴代码...
在做这个项目的时候我发现一个问题,假如不是使用机器的内存,而是使用硬件的内存的时候,一定要手动Flush硬件的内存.
我相信这个问题在做东进语音卡项目的时候很多人都会遇到.
好,继续开贴...
![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
myTelNum
1
using System;
2
using System.Data;
3
using System.Data.Sql;
4
using System.Data.SqlClient;
5
using System.Configuration;
6
using System.Collections.Generic;
7
using System.Text;
8![](https://cnherman.cnblogs.com/Images/OutliningIndicators/None.gif)
9
namespace DJVoiceCard.DBMod
10![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
11![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
12
/// 电话号码连接层.连同数据处理;
13
/// </summary>
14
public class myTelNum
15![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
16
private string SqlConnString = ConfigurationSettings.AppSettings["LinkStr"];
17![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
private string _newTelNum=string.Empty;
19
private string _newTelPass=string.Empty;
20
private string[] _newTelStr=new string[2];
21![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
22
/// 构造连接层
23
/// </summary>
24
public myTelNum()
25![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
26
newTelNum();
27
}
28![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
数据获取操作#region 数据获取操作
29![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
30
/// 获取新电话用户得号码
31
/// </summary>
32
private void newTelNum()
33![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
34
string telTemp = string.Empty;
35
SqlConnection sqlConn = new SqlConnection(SqlConnString);
36
string sqlStr = "select top 1* from xwtx_reg_telUser where iIsPassSend=0";
37
SqlDataReader sqlReader;
38
sqlReader = null;
39![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
40
SqlCommand sqlComm = new SqlCommand(sqlStr, sqlConn);
41
sqlConn.Open();
42
sqlReader = sqlComm.ExecuteReader();
43
if (sqlReader.Read())
44![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
45
if (sqlReader["sTelUserID"]!=null)
46![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
47
_newTelStr[0] = sqlReader["sTelUserID"].ToString();
48
}
49
else
50![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
51
_newTelStr[0] = string.Empty;
52
}
53![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
54
if (sqlReader["sTelUserPass"] != null)
55![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
56
_newTelStr[1] = sqlReader["sTelUserPass"].ToString();
57
}
58
else
59![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
60
_newTelStr[1] = string.Empty;
61
}
62
}
63
else
64![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
65
66
}
67
sqlReader.Close();
68
sqlConn.Close();
69
sqlComm.Dispose();
70
}
71![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
72
/// 取得电话号码
73
/// </summary>
74
public string theTelNum
75![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
76![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{
77
if (_newTelStr != null)
78![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
79
newTelNum();
80
if (_newTelStr.Length == 2)
81![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
82
if (_newTelStr[0] != null)
83![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
84
_newTelNum = _newTelStr[0];
85
}
86
else
87![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
88
_newTelNum="";
89
}
90
}
91
else
92![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ _newTelNum = ""; }
93
}
94
return _newTelNum; }
95
96
}
97![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
98![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
99
/// 获取电话号码对应得密码
100
/// </summary>
101
public string theTelPass
102![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
103![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{
104
if (_newTelStr != null)
105![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
106
if (_newTelStr.Length == 2)
107![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
108
if (_newTelStr[1] != null)
109![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
110
_newTelPass = _newTelStr[1];
111
}
112
else
113![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
114
_newTelPass = "";
115
}
116
}
117
else
118![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ _newTelPass = ""; }
119
}
120
return _newTelPass;
121
}
122
}
123![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
124![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
125
/// 根据号码获取密码
126
/// </summary>
127
/// <param name="TelNum"></param>
128
/// <returns></returns>
129
public string GetTelPass(string TelNum)
130![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
131
string Pass = string.Empty;
132
SqlConnection sqlConn = new SqlConnection(SqlConnString);
133
string sqlStr = "select * from xwtx_reg_telUser where sTelUserID='" + TelNum + "'";
134
SqlDataReader sqlReader;
135
sqlReader = null;
136
SqlCommand sqlComm = new SqlCommand(sqlStr, sqlConn);
137
sqlConn.Open();
138
sqlReader = sqlComm.ExecuteReader();
139
if (sqlReader.Read())
140![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
141
if (sqlReader["sTelUserPass"] != null)
142![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
143
Pass = sqlReader["sTelUserPass"].ToString();
144
}
145
else
146![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
147
Pass = string.Empty;
148
}
149
}
150
else
151![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
152![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
153
}
154
sqlReader.Close();
155
sqlConn.Close();
156
sqlComm.Dispose();
157
return Pass;
158
}
159![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
160
#endregion
161![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
162![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
数据更新#region 数据更新
163![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
164
/// 密码发送成功
165
/// </summary>
166
/// <param name="TelNum"></param>
167
/// <returns></returns>
168
private bool ISupdateTelNum(string TelNum)
169![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
170
if (TelNum==string.Empty)
171![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
172
TelNum = "0";
173
}
174
string sqlStr = "Update xwtx_reg_telUser set iIsPassSend=1 where sTelUserID='" + TelNum + "'";
175
SqlConnection sqlconn = new SqlConnection(SqlConnString);
176
SqlCommand sqlComm = new SqlCommand(sqlStr, sqlconn);
177
try
178![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
179
sqlconn.Open();
180
sqlComm.ExecuteNonQuery();
181
182
sqlconn.Close();
183
return true;
184
}
185
catch
186![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
187
if (sqlconn.State.ToString().ToLower() != "closed")
188![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ sqlconn.Close(); }
189
return false;
190
}
191
}
192![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
193
/// 密码发送后调用
194
/// </summary>
195
public bool ISmodify
196![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
197![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return ISupdateTelNum(_newTelNum); }
198
}
199![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
200
public bool ISCompelet(string TelNum)
201![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
202
return ISupdateTelNum(TelNum);
203
}
204![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
205
/// 密码发送失败
206
/// </summary>
207
/// <param name="TelNum"></param>
208
public void FailSend(string TelNum)
209![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
210
if (TelNum == string.Empty)
211![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
212
TelNum = "0";
213
}
214
string sqlStr = "Update xwtx_reg_telUser set iIsPassSend=3 where sTelUserID='" + TelNum + "'";
215
SqlConnection sqlconn = new SqlConnection(SqlConnString);
216
SqlCommand sqlComm = new SqlCommand(sqlStr, sqlconn);
217
try
218![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
219
sqlconn.Open();
220
sqlComm.ExecuteNonQuery();
221![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
222
sqlconn.Close();
223
224
}
225
catch
226![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
227
if (sqlconn.State.ToString().ToLower() != "closed")
228![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ sqlconn.Close(); }
229
230
}
231
}
232
#endregion
233![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
234![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
日志记录#region 日志记录
235
public void LogModify(string TelNum,string ErrorMessage)
236![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
237
if (TelNum == string.Empty)
238![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
239
TelNum = "0";
240
}
241
string sqlStr = "insert into xwtx_reg_telUser_Log(logContxt,logDate) values('发送用户" + TelNum + "密码时,发生" + ErrorMessage + ":错误','" + DateTime.Now + "')";
242
SqlConnection sqlconn = new SqlConnection(SqlConnString);
243
SqlCommand sqlComm = new SqlCommand(sqlStr, sqlconn);
244
try
245![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
246
sqlconn.Open();
247
sqlComm.ExecuteNonQuery();
248![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
249
sqlconn.Close();
250![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
251
}
252
catch
253![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
254
if (sqlconn.State.ToString().ToLower() != "closed")
255![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ sqlconn.Close(); }
256![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
257
}
258
}
259
#endregion
260![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
261
}
262
}
263![](https://cnherman.cnblogs.com/Images/OutliningIndicators/None.gif)
这段是获取数据库里面的东东的.具体来说对整个例子的意义不大..
下面开始的是业务逻辑部分.个人觉得是比较重要的部分.里面有很多代码没有经过优化.我贴出来了.希望大家不要骂我呃.
![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
DailMain
1
using System;
2
using System.Collections.Generic;
3
using System.Configuration;
4
using System.ComponentModel;
5
using System.Data;
6
using System.Drawing;
7
using System.Text;
8
using System.Windows.Forms;
9
using DJVoiceCard.DL;
10
using System.Runtime.InteropServices;
11
using DJVoiceCard.Lib;
12
using System.Data.OleDb;
13
using System.IO;
14
using System.Threading;
15
using DJVoiceCard.DBMod;
16![](https://cnherman.cnblogs.com/Images/OutliningIndicators/None.gif)
17
namespace DJVoiceCard.App
18![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
19
public partial class DailMain : Form
20![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
21![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
//private static string[] _FileArr;
23![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////// <summary>
25
///// 语音文件路径
26
///// </summary>
27
//public string[] FileArr { get { return _FileArr; } set { _FileArr = value; } }
28
//private static string _CalloutST=string.Empty;
29![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
30![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////// <summary>
31
///// 调用状态
32
///// </summary>
33
//public static string CalloutST
34
//{
35
// get { return _CalloutST; }
36
// set { _CalloutST = value; }
37
//}
38![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
39
/// 中继通道总数;
40
/// </summary>
41
private int iTunkTotal;
42![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
43
/// 用户通道数
44
/// </summary>
45
private int iUserTotal;
46![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
47![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
48
/// 主叫电话号码
49
/// </summary>
50
public string MyCallNO =ConfigurationSettings.AppSettings["calleeNum"];
51
public string WelcomeTo=ConfigurationSettings.AppSettings["Welcome"];
52
public string PassReadBegin = ConfigurationSettings.AppSettings["PassReadBegin"];
53
public string PassRead = ConfigurationSettings.AppSettings["PassRead"];
54
public string EndSystem = ConfigurationSettings.AppSettings["EndSystem"];
55
private string DbPath = ConfigurationSettings.AppSettings["LinkStr"];
56
private string CallOutNum = string.Empty;
57![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
58
public string VoiceST = string.Empty;
59
ulong nOutCall ;
60
ulong nMyCallNo ;
61![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
62![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
63
/// 公共线程,主要用来拨号
64
/// </summary>
65
//public Thread TheadCall;
66![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
67![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
68
/// 信道使用状态
69
/// </summary>
70
public string TrunkState=string.Empty;
71![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
72
/// 用户状态
73
/// </summary>
74
public UR_ST[] URS = new UR_ST[120];
75![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
76![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
77
/// 信道状态
78
/// </summary>
79
public TRK_ST[] TST = new TRK_ST[120];
80
string[] CallST=new string[120];
81
int[] arrVoiceChn=new int[10];
82
public DailMain()
83![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
84
InitializeComponent();
85
}
86![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
87
private void Dail_Load(object sender, EventArgs e)
88![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
89
SysInit();
90
}
91![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
92
private void DailMain_FormClosing(object sender, FormClosingEventArgs e)
93![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
94
ReacurseTrunk();
95
SysFunction.SysExit();
96
this.Dispose();
97
base.Dispose();
98
}
99![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
100
private void btnExit_Click(object sender, EventArgs e)
101![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
102
ExitSys();
103
}
104![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
105
private void TimeChk_Tick(object sender, EventArgs e)
106![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
107
SysFunction.Push_GerEvent();
108
TrunkTimerWork();
109
StateView();
110
dbCall();
111
}
112![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
113
private void btnCall_Click(object sender, EventArgs e)
114![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
115
string telNum=txtTelNO.Text.Trim();
116
if (telNum.Length < 6)
117![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
118
119
MessageBox.Show("请输入正确的号码");
120
txtTelNO.Text = "";
121
}
122
else
123![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
124
CallOut(telNum);
125
}
126![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
127
}
128![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
129![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
初始化系统#region 初始化系统
130![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
131
/// 初始化系统
132
/// </summary>
133
private void SysInit()
134![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
135
string sErr = string.Empty;
136
bool isSysLoad = SysFunction.SysInit(ref sErr);
137
if (isSysLoad)
138![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
139
iTunkTotal = SysFunction.iTrkTotal();
140
for (int i = 0; i < iTunkTotal; i++)
141![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
142
TST[i].ConnTrID = -1;
143
TST[i].ConnUrID = -1;
144
TST[i].ST = TRUNK_ST.TRK_FREE;
145
TST[i].DialNum = string.Empty;
146
}
147![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
148
iUserTotal = SysFunction.iUserTotal();
149
for (int i = 0; i < iUserTotal; i++)
150![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
151
SysFunction.UserPowerOn(i);
152
if (SysFunction.UserEnableDailSound(i))
153![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
154
URS[i].ConnTrID = -1;
155
URS[i].ConnTrID = -1;
156
URS[i].ST = USER_STATE.USR_ONHOOK;
157
}
158
else
159![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
160
MessageBox.Show("初始化用户模块失败");
161
ExitSys();
162
break;
163
}
164
}
165![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
166
arrVoiceChn[1] = SysFunction.iFreeVoiceCHNID();
167
StringBuilder busy = new StringBuilder("BUSY");
168
if (SysFunction.LoopVoiceM(arrVoiceChn[1], busy))
169![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
170![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
171
}
172
arrVoiceChn[2] = SysFunction.iFreeVoiceCHNID();
173
StringBuilder ring = new StringBuilder("RING");
174
if (SysFunction.LoopVoiceM(arrVoiceChn[2], ring))
175![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
176![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
177
}
178
arrVoiceChn[3] = SysFunction.iFreeVoiceCHNID();
179
StringBuilder tone = new StringBuilder("TONE");
180
if (SysFunction.LoopVoiceM(arrVoiceChn[2], tone))
181![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
182![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
183
}
184![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
185
lvChn.BeginUpdate();
186
for (int i = 0; i < iTunkTotal; i++)
187![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
188
ListViewItem lvi = new ListViewItem();
189
lvi.Text = i.ToString();
190
lvi.SubItems.Add("");
191
lvi.SubItems.Add("");
192
lvi.SubItems.Add("");
193
lvi.SubItems.Add("");
194
lvi.SubItems.Add("");
195
lvi.SubItems.Add("");
196
lvChn.Items.Add(lvi);
197
}
198
lvChn.EndUpdate();
199
StateView();
200
}
201
else
202![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
203
//MessageBox.Show(sErr);
204
// ExitSys();
205
}
206
}
207
#endregion
208![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
209![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
Exit System#region Exit System
210![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
211
/// 退出系统
212
/// </summary>
213
public void ExitSys()
214![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
215
ReacurseTrunk();
216
SysFunction.SysExit();
217
this.Dispose();
218
base.Dispose();
219
}
220![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
221![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
222
#endregion
223![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
224![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
数据处理#region 数据处理
225![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
226
/// 读取数据 拨号
227
/// </summary>
228
public void dbCall()
229![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
230
if (TrunkState != "Calling")
231![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
232
myTelNum mytel = new myTelNum();
233
if (mytel.theTelNum != string.Empty)
234![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
235
lblMsg.Text = DateTime.Now.ToString()+"自动发送";
236
TheadCallOut();
237
}
238
else
239![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
240
lblMsg.Text = DateTime.Now + "无可用号码";
241
}
242
243
}
244
else
245![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
246
lblMsg.Text = DateTime.Now+"自动发送信道使用中
";
247
}
248
}
249
#endregion
250![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
251![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
更新控件数据显示#region 更新控件数据显示
252![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
253![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
254
/// 向控件更新数据
255
/// </summary>
256
public void StateView()
257![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
258
SysFunction.Push_GerEvent();
259
iTunkTotal = SysFunction.iTrkTotal();
260
for (int i = 0; i < iTunkTotal; i++)
261![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
262
DrawTrunkState(i);
263
}
264
}
265
#endregion
266![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
267![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
信道状态轮询#region 信道状态轮询
268![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
269
/// 轮询
270
/// </summary>
271
public void TrunkTimerWork()
272![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
273
//int iVoiceID;
274
int iResult;
275
iTunkTotal = SysFunction.iTrkTotal();
276![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
277
for (int i = 0; i < iTunkTotal; i++)
278![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
279![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
280
iResult = SysFunction.iRaleyStetes((byte)(i / 30), (byte)(i % 30));
281
if (iResult == (int)RelayStates.ISUP_CH_WAIT_RELEASE)
282![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
283
VoiceST =string.Empty;
284
TrunkState = string.Empty;
285
ReaseceTrunckCHN(i);
286
SysFunction.SetRelayStates(i, (int)RelayStates.ISUP_CH_FREE);
287
lvChn.BeginUpdate();
288
lvChn.Items[i].SubItems[5].Text = "";
289
lvChn.EndUpdate();
290
}
291![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
292
if (SysFunction.iRaleyStetes(((byte)(i / 30)), ((byte)(i % 30))) == (int)RelayStates.ISUP_CALLER_CONNECT)
293![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
294
//lblMsg.Text = "去话连通.";
295
TrunkState = "Calling";
296
bool beFinish = false;
297
int iST = SysFunction.iCallOutStates(i / 30, i % 30);
298
string calleeNum = CalleeNum(i / 30, i % 30);
299![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
处理声音播放#region 处理声音播放
300
unsafe
301![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
302
byte[] filePath = GetFilePath(WelcomeTo);
303![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
304
try
305![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
306
TrunkState = "Calling";
307
lblTrunk.Text = "信道状态是:" + VoiceST;
308![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
注释掉的东西,以后备用#region 注释掉的东西,以后备用
309![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*if (Convert.ToBoolean(iST & 0x10))
310
{
311
int iCPGval = SysFunction.iCPGReval(i);
312
int iISUPval = SysFunction.ISUPReVal(i);
313
}*/
314![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
315
//if (SysFunction.iRaleyStetes(((byte)(i / 30)), ((byte)(i % 30))) == (int)RelayStates.ISUP_CALLER_CONNECT)
316
//{
317![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
out#region out
318
//PlayFiles(i);
319
//PlayVoiceBegin(i, MusicFile);
320
//PlayVoice(i, "call.005");
321
//PlayVoiceEnd(i, "call.006");
322![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
323![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*if (SysFunction.bISplayVoice(i, filePath))
324
{
325
beFinish = true;
326
lblMsg.Text += Encoding.UTF8.GetString(filePath);
327
SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
328
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
329
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
330
{
331
SysFunction.StopPlayVocInTrunk(i);
332
ReaseceTrunckCHN(i);
333
beFinish = true;
334
}
335
}
336
else
337
{
338
TST[i].ST = TRUNK_ST.TRK_PLAY;
339
}*/
340![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*
341
bool PlayNext = false;
342![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
343
if(SysFunction.bISplayVoice(i,filePath))
344
{
345
if (PlayNext)
346
{
347
SysFunction.StopPlayVocInTrunk(i);
348
ReaseceTrunckCHN(i);
349
}
350
if (!PlayNext)
351
{
352
SysFunction.StopPlayVocInTrunk(i);
353
ReaseceTrunckCHN(i);
354
}
355
}
356
beFinish = true;
357
* */
358
359![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*if (SysFunction.bISplayVoice(i, filePath))
360
{
361
lblMsg.Text += Encoding.UTF8.GetString(filePath);
362
SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
363
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
364
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
365
{
366
SysFunction.StopPlayVocInTrunk(i);
367
ReaseceTrunckCHN(i);
368
beFinish = true;
369
}
370
}*/
371
#endregion
372
//MessageBox.Show(VoiceST);
373![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
声音播放状态判断#region 声音播放状态判断
374
//声音播放状态
375![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*
376
switch (VoiceST)
377
{
378
case "Callout":
379
{
380
lblTrunk.Text = "信道状态是:" + VoiceST;
381
SysFunction.bISplayVoice(i, filePath);
382
VoiceST = "Welcome";
383
//if (SysFunction.bISplayVoice(i, filePath))
384
//{
385
SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
386
//int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
387
//if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
388
//{
389
// lblTrunk.Text = "信道状态是:" + VoiceST;
390
// //SysFunction.StopPlayVocInTrunk(i);
391
// //ReaseceTrunckCHN(i);
392
// //beFinish = true;
393
// VoiceST = "Welcome";
394
//}
395
//}
396
break;
397
}
398
case "Welcome":
399
{
400
lblTrunk.Text = "信道状态是:" + VoiceST;
401
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
402
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
403
{
404
SysFunction.bISplayVoice(i, GetFilePath("bank.005"));
405
VoiceST = "ReadUser";
406
//if (SysFunction.bISplayVoice(i, GetFilePath("bank.005")))
407
//{
408
// SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
409
// int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
410
// if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
411
// {
412
// lblTrunk.Text = "信道状态是:" + VoiceST;
413
// //SysFunction.StopPlayVocInTrunk(i);
414
// //ReaseceTrunckCHN(i);
415
// //beFinish = true;
416
// VoiceST = "ReadUser";
417
// }
418
//}
419
}
420
break;
421
}
422
case "ReadUser":
423
{
424
lblTrunk.Text = "信道状态是:" + VoiceST;
425
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
426
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
427
{
428
SysFunction.bISplayVoice(i, GetFilePath("bank.006"));
429
VoiceST = "SendUser";
430
//if (SysFunction.bISplayVoice(i, GetFilePath("bank.006")))
431
//{
432
// SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
433
// int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
434
// if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
435
// {
436
// lblTrunk.Text = "信道状态是:" + VoiceST;
437
// //SysFunction.StopPlayVocInTrunk(i);
438
// //ReaseceTrunckCHN(i);
439
// //beFinish = true;
440
// VoiceST = "SendUser";
441
// }
442
//}
443
}
444
break;
445
}
446
case "SendUser":
447
{
448
lblTrunk.Text = "信道状态是:" + VoiceST;
449
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
450
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
451
{
452
SysFunction.bISplayVoice(i, GetFilePath("bank.007"));
453
VoiceST = "ReadPass";
454
//if (SysFunction.bISplayVoice(i, GetFilePath("bank.007")))
455
//{
456
// SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
457
// int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
458
// if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
459
// {
460
// lblTrunk.Text = "信道状态是:" + VoiceST;
461
// //SysFunction.StopPlayVocInTrunk(i);
462
// //ReaseceTrunckCHN(i);
463
// //beFinish = true;
464
// VoiceST = "ReadPass";
465
// }
466
//}
467
}
468
break;
469
}
470
case "ReadPass":
471
{
472
lblTrunk.Text = "信道状态是:" + VoiceST;
473
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
474
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
475
{
476
SysFunction.bISplayVoice(i, GetFilePath("bank.001"));
477
VoiceST = "SendPass";
478
//if (SysFunction.bISplayVoice(i, GetFilePath("bank.001")))
479
//{
480
// SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
481
// int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
482
// if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
483
// {
484
// lblTrunk.Text = "信道状态是:" + VoiceST;
485
// //SysFunction.StopPlayVocInTrunk(i);
486
// //ReaseceTrunckCHN(i);
487
// //beFinish = true;
488
// VoiceST = "SendPass";
489
// }
490
//}
491
}
492
break;
493
}
494
case "SendPass":
495
{
496
lblTrunk.Text = "信道状态是:" + VoiceST;
497
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
498
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
499
{
500
SysFunction.bISplayVoice(i, GetFilePath("D1"));
501
VoiceST = "ReSendPass";
502
//if (SysFunction.bISplayVoice(i, GetFilePath("D1")))
503
//{
504
// SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
505
// int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
506
// if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
507
// {
508
// lblTrunk.Text = "信道状态是:" + VoiceST;
509
// //SysFunction.StopPlayVocInTrunk(i);
510
// //ReaseceTrunckCHN(i);
511
// //beFinish = true;
512
// VoiceST = "ReSendPass";
513
// }
514
//}
515
}
516
break;
517
}
518
case "ReSendPass":
519
{
520
lblTrunk.Text = "信道状态是:" + VoiceST;
521
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
522
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
523
{
524
SysFunction.bISplayVoice(i, GetFilePath("D1"));
525
VoiceST = "EndSystem";
526
//if (SysFunction.bISplayVoice(i, GetFilePath("D1")))
527
//{
528
// SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
529
// int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
530
// if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
531
// {
532
// lblTrunk.Text = "信道状态是:" + VoiceST;
533
// //SysFunction.StopPlayVocInTrunk(i);
534
// //ReaseceTrunckCHN(i);
535
// //beFinish = true;
536
// VoiceST = "EndSystem";
537
// }
538
//}
539
}
540
break;
541
}
542
case "EndSystem":
543
{
544
lblTrunk.Text = "信道状态是:" + VoiceST;
545
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
546
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
547
{
548
SysFunction.bISplayVoice(i, GetFilePath("bank.002"));
549
VoiceST = "ExitSystem";
550
//if (SysFunction.bISplayVoice(i, GetFilePath("bank.002")))
551
//{
552
// SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
553
// int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
554
// if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
555
// {
556
// lblTrunk.Text = "信道状态是:" + VoiceST;
557
// SysFunction.StopPlayVocInTrunk(i);
558
// ReaseceTrunckCHN(i);
559
// beFinish = true;
560
// VoiceST = "";
561
// }
562
//}
563
}
564
break;
565
}
566
case "ExitSystem":
567
{
568
lblTrunk.Text = "信道状态是:" + VoiceST;
569
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
570
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
571
{
572
SysFunction.StopPlayVocInTrunk(i);
573
ReaseceTrunckCHN(i);
574
beFinish = true;
575
}
576
//if (SysFunction.bISplayVoice(i, filePath))
577
//{
578
// SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
579
// int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
580
// if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
581
// {
582
// lblTrunk.Text = "信道状态是:" + VoiceST;
583
// //SysFunction.StopPlayVocInTrunk(i);
584
// //ReaseceTrunckCHN(i);
585
// //beFinish = true;
586
// VoiceST = "Welcome";
587
// }
588
//}
589
break;
590
}
591
default:
592
{
593
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(i);
594
if (SysFunction.bIsVocPlayEnd(iVoiceLinkTunk))
595
{
596
SysFunction.StopPlayVocInTrunk(i);
597
ReaseceTrunckCHN(i);
598
beFinish = false;
599
}
600
break;
601
}
602
603![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
604
}
605
*/
606
#endregion
607
//}
608![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
609
#endregion
610![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
611
if (VoiceST == "Callout")
612![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
613
myTelNum tn = new myTelNum();
614
string TelNum = calleeNum;
615
SysFunction.PlayFileInit(i);
616
AddIndexFiles(i, WelcomeTo);
617
string SysCalleeNum = Encoding.UTF8.GetString(SysFunction.GetCallNum(i / 30, i % 30).bCallNum);
618
string TelPass = tn.GetTelPass(SysCalleeNum);
619
for (int t = 0; t < SysCalleeNum.Length; t++)
620![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
621
string tmp = "d" + SysCalleeNum[t].ToString();
622
AddIndexFiles(i, tmp.Trim());
623
}
624
if (TelPass != string.Empty || TelPass != null)
625![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
626
AddIndexFiles(i, PassReadBegin);
627
AddIndexFiles(i, PassRead);
628
for (int p = 0; p < TelPass.Length; p++)
629![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
630
string ptmp = "d" + TelPass[p].ToString();
631
AddIndexFiles(i, ptmp.Trim());
632
}
633
AddIndexFiles(i, PassRead);
634
for (int p = 0; p < TelPass.Length; p++)
635![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
636
string ptmp = "d" + TelPass[p].ToString();
637
AddIndexFiles(i, ptmp.Trim());
638
}
639
}
640
AddIndexFiles(i, EndSystem);
641
SysFunction.PlayFileStart(i);
642
VoiceST="FilePlay";
643
}
644![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
645
if (VoiceST == "FilePlay")
646![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
647
if (SysFunction.PlayFileEndCHK(i))
648![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
649
VoiceST = "PlayEnd";
650
}
651
//if()
652
}
653
if (VoiceST == "PlayEnd")
654![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
655
SysFunction.PlayFileEnd(i);
656
beFinish = true;
657
}
658![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
659
}
660
catch (Exception ex)
661![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
662
lblTrunk.Text =ex.Message.ToString();
663
664
myTelNum tn = new myTelNum();
665
tn.LogModify(Encoding.UTF8.GetString(SysFunction.GetCallNum(i / 30, i % 30).bCallNum), ex.Message);
666
beFinish = false;
667
ReaseceTrunckCHN(i);
668
SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_FREE);
669
TrunkState = string.Empty;
670
671
}
672
}
673![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
674
//数据插入
675
if (beFinish)
676![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
677
lblTrunk.Text = "播放结束";
678
myTelNum mt = new myTelNum();
679
mt.ISCompelet(Encoding.UTF8.GetString(SysFunction.GetCallNum(i / 30, i % 30).bCallNum));
680
SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
681
ReaseceTrunckCHN(i);
682
SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_FREE);
683
TrunkState = string.Empty;
684
VoiceST = string.Empty;
685
}
686
else
687![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
688
//MessageBox.Show("beFinish:" + beFinish.ToString());
689![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*ReaseceTrunckCHN(i);
690
myTelNum tn = new myTelNum();
691
tn.LogModify(calleeNum,"密码发送失败");
692
beFinish = false;
693
SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_FREE);
694
TrunkState = string.Empty;*/
695
696
}
697
#endregion
698
}
699![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
700
//if (SysFunction.iRaleyStetes(((byte)(i / 30)), ((byte)(i % 30))) == (int)RelaySet.ISUP_CH_SET_REL)
701
//{
702
// lblTrunk.Text = "播放完毕,准备挂机";
703
// ReaseceTrunckCHN(i);
704
// SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_FREE);
705
// TrunkState = string.Empty;
706
// VoiceST = string.Empty;
707
//}
708![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
709
if (SysFunction.iRaleyStetes(((byte)(i / 30)), ((byte)(i % 30))) == (int)RelayStates.ISUP_CALLER_WAIT_ANM)
710![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
711
TrunkState = "Calling";
712
lblMsg.Text = "等待被叫响应";
713
}
714
if (SysFunction.iRaleyStetes(((byte)(i / 30)), ((byte)(i % 30))) == (int)RelayStates.ISUP_CALLEE_RECV_IAM)
715![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
716
TrunkState = "Calling";
717
lblMsg.Text = "呼叫到达";
718
}
719![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
注释掉的东西不知道以后有没有用哈#region 注释掉的东西不知道以后有没有用哈
720![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*if (TST[i].ST == TRUNK_ST.TRK_PLAY)
721
{
722
iVoiceID = SysFunction.iVoicePlayForTrunk(i);
723
if (iVoiceID == -1)
724
{
725
SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
726
return;
727
}
728
else
729
{
730
if (SysFunction.bIsVocPlayEnd(iResult))
731
{
732
SysFunction.StopPlayVocInTrunk(i);
733
SysFunction.SetRelayStates(i, (int)RelaySet.ISUP_CH_SET_REL);
734
TST[i].ST = TRUNK_ST.TRK_HANGUP;
735
}
736
}
737
}*/
738
#endregion
739
}
740
}
741
#endregion
742![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
743![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
播放声音#region 播放声音
744![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
745![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
746
/// 开始播放声音
747
/// </summary>
748
/// <param name="TrunkID"></param>
749
/// <param name="FileNames"></param>
750
public void PlayVoiceBegin(int TrunkID, string FileNames)
751![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
752
byte[] filePath = GetFilePath(FileNames);
753
//int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(TrunkID);
754
if (SysFunction.iRaleyStetes(((byte)(TrunkID / 30)), ((byte)(TrunkID % 30))) == (int)RelayStates.ISUP_CALLEE_CONNECT)
755![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
756
bool IsPlay = SysFunction.bISplayVoice(TrunkID, filePath);
757
}
758
}
759![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
760![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
761
/// 连续播放声音
762
/// </summary>
763
/// <param name="TrunkID"></param>
764
/// <param name="FileNames"></param>
765
public void PlayVoice(int TrunkID, string FileNames)
766![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
767
byte[] filePath = GetFilePath(FileNames);
768
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(TrunkID);
769
if (SysFunction.bIsVocPlayEnd(TrunkID))
770![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
771
bool IsPlay = SysFunction.bISplayVoice(TrunkID, filePath);
772
if(IsPlay)
773![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
774
SysFunction.StopPlayVocInTrunk(TrunkID);
775
ReaseceTrunckCHN(TrunkID);
776
//beFinish = true;
777
//此处处理程序;
778
}
779
}
780
}
781![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
782
public void PlayVoiceEnd(int TrunkID, string FileNames)
783![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
784
byte[] filePath = GetFilePath(FileNames);
785
int iVoiceLinkTunk = SysFunction.iVoicePlayForTrunk(TrunkID);
786
if (SysFunction.bIsVocPlayEnd(TrunkID))
787![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
788
bool IsPlay = SysFunction.bISplayVoice(TrunkID, filePath);
789
if (IsPlay)
790![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
791
//此处处理程序;
792
}
793
}
794
}
795
#endregion
796![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
797![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
索引播音(多文件播音)#region 索引播音(多文件播音)
798![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
799![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
800
/// 添加索引音乐文件
801
/// </summary>
802
/// <param name="TrunkID"></param>
803
/// <param name="FileNames"></param>
804
public void AddIndexFiles(int TrunkID,string FileNames)
805![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
806
byte[] FileArr = GetFilePath(FileNames);
807
SysFunction.AddIndexFile(TrunkID, FileArr);
808
}
809![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
810
#endregion
811![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
812![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
中继通道状态遍历#region 中继通道状态遍历
813![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
814
/// 信道状态
815
/// </summary>
816
/// <param name="iTrunkID"></param>
817
/// <returns></returns>
818
819
public void DrawTrunkState(int iTrunkID)
820![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
821
string sST = string.Empty;
822
string sCalleeNum = string.Empty;
823
string sCallerNum = string.Empty;
824
int iTrunkST = SysFunction.iRaleyStetes((byte)(iTrunkID / 30), (byte)(iTrunkID % 30));
825
switch (iTrunkST)
826![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
827
case (int)RelayStates.ISUP_CH_WAIT_RELEASE:
828![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
829
sST = ("不可用");
830
break;
831
}
832
case (int)RelayStates.ISUP_CH_FREE:
833![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
834
sST = ("空闲");
835
break;
836
}
837
case (int)RelayStates.ISUP_CALLEE_CONNECT:
838![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
839
sST = ("来话摘机");
840
break;
841
}
842
case (int)RelayStates.ISUP_CALLER_CONNECT:
843![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
844
TrunkState = "Calling";
845
sCalleeNum =Encoding.UTF8.GetString(SysFunction.GetCallNum(iTrunkID / 30, iTrunkID % 30).bCallNum);
846
myTelNum mt = new myTelNum();
847
sCallerNum =mt.GetTelPass(sCalleeNum);
848
sST = "电话呼出";
849
break;
850
}
851
case (int)RelayStates.ISUP_CALLER_WAIT_ANM:
852![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
853
sCalleeNum =Encoding.UTF8.GetString(SysFunction.GetCallNum(iTrunkID / 30, iTrunkID % 30).bCallNum);
854
sCallerNum = Encoding.UTF8.GetString(SysFunction.GetCallNum(iTrunkID / 30, iTrunkID % 30).bCalleeNum);
855
TrunkState = "Calling";
856
VoiceST = "Callout";
857
sST = "呼出等待";
858
break;
859
}
860
case (int)RelayStates.ISUP_CH_LOCAL_BLOCK:
861![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
862
sST = "本地闭塞";
863
break;
864
}
865
case (int)RelayStates.ISUP_CH_LOCAL_SUSPEND:
866![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
867
sST = "本地暂停";
868
break;
869
}
870
case (int)RelayStates.ISUP_CH_REMOTE_BLOCK:
871![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
872
sST = "远端闭塞";
873
break;
874
}
875
case (int)RelayStates.ISUP_CH_REMOTE_SUSPEND:
876![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
877
sST = "远端暂停";
878
break;
879
}
880
default:
881![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
882
sST = "中间状态";
883
break;
884![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
885
}
886
}
887
lvChn.Items[iTrunkID].SubItems[3].Text = sST;
888
lvChn.Items[iTrunkID].SubItems[4].Text = sCallerNum;
889
lvChn.Items[iTrunkID].SubItems[5].Text = sCalleeNum;
890
}
891
#endregion
892![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
893![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
声音文件转换#region 声音文件转换
894![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
895
/// 文件名转换成byte[]
896
/// </summary>
897
/// <param name="FileName"></param>
898
/// <returns></returns>
899
public byte[] GetFilePath(string FileName)
900![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
901
string appFile = SysFunction.appDIRStr().ToString();
902
//MessageBox.Show(appFile);
903
char[] charTemp = new char[256];
904
byte[] byteTemp = new byte[256];
905
long Pos = 0;
906
long tmp = 0;
907![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
908![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
909
appFile.ToCharArray().CopyTo(charTemp, Pos);
910
for (short x = 0; x < charTemp.Length; x++)
911![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
912
if (charTemp[x] != 0)
913![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
914
tmp++;
915
}
916
}
917
Pos = tmp;
918
@"voc\".ToCharArray().CopyTo(charTemp, Pos);
919
FileName.ToCharArray().CopyTo(charTemp, Pos + 4);
920
Encoding.Unicode.GetBytes(FileName.ToCharArray()).CopyTo(byteTemp, 0);
921
for (int i =0; i < charTemp.Length; i++)
922![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
923
byteTemp[i] = (byte)charTemp[i];
924
}
925
return byteTemp;
926
}
927
#endregion
928![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
929![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
电话号码转换#region 电话号码转换
930![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
931
/// 电话号码转换
932
/// </summary>
933
/// <param name="Str"></param>
934
/// <param name="PCMno"></param>
935
/// <param name="RelayNo"></param>
936
/// <returns></returns>
937
public byte[] CalleestringTobyte(string Str,int PCMno,int RelayNo)
938![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
939
TC_INI_TYPE TC = new TC_INI_TYPE();
940
char[] charTemp = new char[256];
941
byte[] byteTemp = new byte[256];
942
long Pos = 0;
943
long tmp = 0;
944![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
945![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
946
TC=SysFunction.GetCallNum(PCMno,RelayNo);
947
TC.bCalleeNum.CopyTo(byteTemp, Pos);
948
for (short x = 0; x < Pos;x++ )
949![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
950
if(TC.bCalleeNum[x]!=0)
951![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
952
tmp++;
953
}
954
}
955
Pos = tmp;
956
Encoding.Unicode.GetBytes(Str.ToCharArray()).CopyTo(byteTemp, 0);
957
return byteTemp;
958
}
959
#endregion
960![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
961![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
被叫电话号码#region 被叫电话号码
962
public string CalleeNum(int PCMno, int RelayNo)
963![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
964
TC_INI_TYPE TC = new TC_INI_TYPE();
965
char[] charTemp = new char[256];
966
byte[] byteTemp = new byte[256];
967
long Pos = 0;
968
long tmp = 0;
969![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
970![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
971
TC = SysFunction.GetCallNum(PCMno, RelayNo);
972
TC.bCalleeNum.CopyTo(byteTemp, Pos);
973
for (short x = 0; x < Pos; x++)
974![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
975
if (TC.bCalleeNum[x] != 0)
976![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
977
tmp++;
978
}
979
}
980
Pos = tmp;
981
// Encoding.Unicode.GetBytes(Str.ToCharArray()).CopyTo(byteTemp, 0);
982
return Encoding.UTF8.GetString(byteTemp);
983
}
984
#endregion
985![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
986![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
拨号#region 拨号
987![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
988
/// 手动拨号
989
/// </summary>
990
///
991
992
public void CallOut(string iTelNum)
993![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
994
995
unsafe
996![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
997
nOutCall = Convert.ToUInt64(iTelNum);
998
nMyCallNo = Convert.ToUInt64(MyCallNO);
999
TelNum telNO = new TelNum();
1000
byte[] iTelNO = new byte[256];
1001
char[] tempTel = new char[256];
1002
tempTel = iTelNum.ToCharArray();
1003
telNO.arrTelNum = Encoding.ASCII.GetBytes(tempTel);
1004
char[] tempCall = new char[256];
1005
byte[] iCallNO = new byte[256];
1006
tempCall = MyCallNO.ToCharArray();
1007
telNO.arrCallNum = Encoding.ASCII.GetBytes(tempCall);
1008
int iFreeTrunkID = SysFunction.iFreePCM();
1009
string sErr = string.Empty;
1010
if (iFreeTrunkID == -1)
1011![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1012
return;
1013
}
1014
else
1015![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1016
StringBuilder sbCallee = new StringBuilder(iTelNum);
1017
StringBuilder sbCaller = new StringBuilder(MyCallNO);
1018
try
1019![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1020
bool charISCallout = SysFunction.bCallOut(iFreeTrunkID, sbCallee, sbCaller);
1021
}
1022
catch (Exception ex)
1023![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1024
lblTrunk.Text = ex.Message;
1025
}
1026![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1027
try
1028![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1029
bool bCallout = SysFunction.bCallOut(iFreeTrunkID, iTelNum, MyCallNO, ref sErr);
1030
}
1031
catch (Exception ex)
1032![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1033
lblTrunk.Text = ex.Message + sErr;
1034
}
1035
try
1036![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1037
bool bISout = SysFunction.bCallOut(iFreeTrunkID, iTelNum, MyCallNO, false, false);
1038
}
1039
catch (Exception ex)
1040![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1041
lblTrunk.Text = ex.Message;
1042
}
1043
try
1044![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1045
bool bIsCallOut = SysFunction.bCallOut(iFreeTrunkID, CalleestringTobyte(iTelNum, iFreeTrunkID / 30, iFreeTrunkID % 30), iCallNO);
1046
}
1047
catch (Exception ex)
1048![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1049
lblTrunk.Text = ex.Message;
1050
}
1051
try
1052![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1053
bool bSisCallOut = SysFunction.bCallOut(iFreeTrunkID, nOutCall, nMyCallNo);
1054
}
1055
catch (Exception ex)
1056![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1057
lblTrunk.Text = ex.Message;
1058
}
1059
lvChn.BeginUpdate();
1060
lvChn.Items[iFreeTrunkID].SubItems[5].Text = iTelNum;
1061
lvChn.EndUpdate();
1062
VoiceST = "Callout";
1063
TrunkState = "Calling";
1064
}
1065
}
1066
1067
}
1068![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1069![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1070![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
1071
/// 自动拨号
1072
/// </summary>
1073
///
1074![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1075
1076
public void TheadCallOut()
1077![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1078
1079
DBMod.myTelNum tn = new DJVoiceCard.DBMod.myTelNum();
1080
string iTelNum = tn.theTelNum;
1081
CallOutNum = tn.theTelNum;
1082
1083
unsafe
1084![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1085
TrunkState = "Calling";
1086
ulong nOutCall = Convert.ToUInt64(iTelNum);
1087
ulong nMyCallNo = Convert.ToUInt64(MyCallNO);
1088
TelNum telNO = new TelNum();
1089
byte[] iTelNO = new byte[256];
1090
char[] tempTel = new char[256];
1091
tempTel = iTelNum.ToCharArray();
1092
telNO.arrTelNum = Encoding.ASCII.GetBytes(tempTel);
1093
char[] tempCall = new char[256];
1094
byte[] iCallNO = new byte[256];
1095
tempCall = MyCallNO.ToCharArray();
1096
telNO.arrCallNum = Encoding.ASCII.GetBytes(tempCall);
1097
int iFreeTrunkID = SysFunction.iFreePCM();
1098
string sErr = string.Empty;
1099
if (iFreeTrunkID == -1)
1100![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1101![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1102
}
1103
else
1104![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1105![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1106
StringBuilder sbCallee = new StringBuilder(iTelNum);
1107
StringBuilder sbCaller = new StringBuilder(MyCallNO);
1108
try
1109![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1110
bool charISCallout = SysFunction.bCallOut(iFreeTrunkID, sbCallee, sbCaller);
1111
}
1112
catch(Exception ex)
1113![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1114
lblTrunk.Text = ex.Message;
1115
}
1116![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1117
try
1118![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1119
bool bCallout = SysFunction.bCallOut(iFreeTrunkID, iTelNum, MyCallNO, ref sErr);
1120
}
1121
catch (Exception ex)
1122![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1123
lblTrunk.Text = ex.Message + sErr;
1124
}
1125
try
1126![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1127
bool bISout = SysFunction.bCallOut(iFreeTrunkID, iTelNum, MyCallNO, false, false);
1128
}
1129
catch (Exception ex)
1130![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1131
lblTrunk.Text = ex.Message;
1132
}
1133
try
1134![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1135
bool bIsCallOut = SysFunction.bCallOut(iFreeTrunkID, CalleestringTobyte(iTelNum, iFreeTrunkID / 30, iFreeTrunkID % 30), iCallNO);
1136
}
1137
catch (Exception ex)
1138![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1139
lblTrunk.Text = ex.Message;
1140
}
1141
try
1142![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1143
bool bSisCallOut = SysFunction.bCallOut(iFreeTrunkID, nOutCall, nMyCallNo);
1144
}
1145
catch (Exception ex)
1146![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1147
lblTrunk.Text = ex.Message;
1148
}
1149
lvChn.BeginUpdate();
1150
lvChn.Items[iFreeTrunkID].SubItems[5].Text = iTelNum;
1151
lvChn.EndUpdate();
1152
TrunkState = "Calling";
1153
VoiceST = "Callout";
1154
}
1155
}
1156
1157
}
1158![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1159
#endregion
1160![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1161![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
释放资源#region 释放资源
1162![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
1163
/// 释放用户通道
1164
/// </summary>
1165
/// <param name="iUserCHNID"></param>
1166
public void ReaseceUserCHN(int iUserCHNID)
1167![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1168
if(iUserCHNID!=-1)
1169![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1170
if(SysFunction.bIsRingDerctor(iUserCHNID))
1171![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1172
if (SysFunction.bIsStopRing(iUserCHNID))
1173![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1174
}
1175
1176
}
1177
if(SysFunction.bClearVoiceFromUser(iUserCHNID))
1178![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{}
1179
if(SysFunction.bIsInitDailBuf(iUserCHNID))
1180![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{}
1181
URS[iUserCHNID].ConnTrID = -1;
1182
URS[iUserCHNID].ConnUrID = -1;
1183
URS[iUserCHNID].ST = USER_STATE.USR_ONHOOK;
1184
1185
}
1186
}
1187![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1188![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
1189
/// 释放中继信道资源
1190
/// </summary>
1191
/// <param name="iTrunkCHNID"></param>
1192
public void ReaseceTrunckCHN(int iTrunkCHNID)
1193![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1194
bool bISCHK = (iTrunkCHNID == -1 && (SysFunction.iRaleyStetes(((byte)(iTrunkCHNID / 30)), ((byte)(iTrunkCHNID % 30))) == (int)RelayStates.ISUP_CH_FREE));
1195
if(!bISCHK)
1196![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1197
int iUserCHNID = SysFunction.iLinkUserCHNID(iTrunkCHNID);
1198
if(iUserCHNID>-1)
1199![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1200
if (SysFunction.ClearCHN(iTrunkCHNID))
1201![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ }
1202
}
1203![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1204
int iVoiceID = SysFunction.iVoicePlayForTrunk(iTrunkCHNID);
1205
if (iVoiceID > -1)
1206![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1207
SysFunction.bIsClearTrunkVoiceLink(iTrunkCHNID);
1208
}
1209![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1210
SysFunction.bIsInitDtmfByTrunkID(iTrunkCHNID);
1211![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1212
TST[iTrunkCHNID].ST = TRUNK_ST.TRK_FREE;
1213
TST[iTrunkCHNID].DialNum = string.Empty;
1214
TST[iTrunkCHNID].ConnTrID = -1;
1215
TST[iTrunkCHNID].ConnUrID = -1;
1216![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1217
SysFunction.SetRelayStates(iTrunkCHNID, (int)RelayStates.ISUP_CH_FREE);
1218
}
1219
}
1220![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
1221
/// 释放资源
1222
/// </summary>
1223
public void ReacurseTrunk()
1224![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1225
iTunkTotal = SysFunction.iTrkTotal();
1226
for (int i = 0; i < iTunkTotal; i++)
1227![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1228
ReaseceTrunckCHN(i);
1229
}
1230
iUserTotal = SysFunction.iUserTotal();
1231
for (int i = 0; i < iUserTotal; i++)
1232![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1233
ReaseceUserCHN(i);
1234
}
1235![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1236
}
1237![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1238
#endregion
1239![](https://cnherman.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1240
private void button1_Click(object sender, EventArgs e)
1241![](https://cnherman.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1242
ReacurseTrunk();
1243
}
1244
}
1245
}
好了,经过贴了那么长的代码.整个项目都已经弄好了.下一篇会吧整个项目贴出来让大家下载.
下載地址