📄 u_innerdealpack.pas
字号:
ADOQuery.Free;
End;
//读取所有功能消息记录
Function ReadAllProviderFunctionMsg(FunctionMsgTableName,DBConnectionString:String;ProviderID:Integer):Boolean;
Var
ADOQuery:TADOQuery;
SqlStr:String;
i:integer;
Begin
Result:=False;
ADOQuery:=TADOQuery.Create(nil);
Try
With ADOQuery Do
Begin
ConnectionString:=DBConnectionString;
SqlStr:='Select * From '+FunctionMsgTableName+' Where Provider_ID=:ProviderID Order By Gate_ID Desc,Title,Order_ID';
Close;Sql.Clear;Sql.Add(SqlStr);
Parameters.ParamByName('ProviderID').Value:=ProviderID;
Open;
SetLength(AllProviderFunctionMsg[ProviderID],RecordCount);
If Not Eof Then
Begin
For i:=0 To RecordCount-1 Do
Begin
AllProviderFunctionMsg[ProviderID][i].Title:=UpperCase(Trim(FieldByName('Title').AsString));
AllProviderFunctionMsg[ProviderID][i].GateID:=FieldByName('Gate_ID').AsInteger;
AllProviderFunctionMsg[ProviderID][i].MsgContent:=Trim(FieldByName('Msg_Content').AsString);
AllProviderFunctionMsg[ProviderID][i].OrderID:=FieldByName('Order_ID').AsInteger;
Next;
End;
End;
AddErrMsg('所有功能消息记录读取成功!('+FunctionMsgTableName+')');
Result:=True;
End;
Except
On E:EOleException Do
Begin
E.ErrorCode:=0;
DBError(E);
End;
End;
ADOQuery.Free;
End;
//获取点拨信息记录
Function GetDialCodeInfoRec(DialCode:String;GateID:Integer):Rec_DialCodeInfo;
Var
DialCodeInfoIndex:Integer;
DialCodeInfoRec:Rec_DialCodeInfo;
Begin
Try
DialCode:=UpperCase(DialCode);
For DialCodeInfoIndex:=0 To DialCodeInfoNum[GateID]-1 Do
Begin
If AllDialCodeInfo[GateID][DialCodeInfoIndex].DialCode=DialCode Then
Begin
Result:=AllDialCodeInfo[GateID][DialCodeInfoIndex];
Exit;
End;
End;
Except
End;
End;
//读取功能消息记录
{
Function SearchMsg(Title:String;GateID:Integer):String;
Var
i,Ilow,ihigh:Integer;
Begin
Title:=UpperCase(Title);
Result:='';
ilow:=Low(AllFunctionMsg);
iHigh:=High(AllFunctionMsg);
For i:=iLow to iHigh Do
Begin
If (AllFunctionMsg[i].Title=Title) And (AllFunctionMsg[i].GateID=GateID) Then
Begin
Result:=AllFunctionMsg[i].MsgContent;
Exit;
End;
If (AllFunctionMsg[i].GateID<0) And (AllFunctionMsg[i].Title=Title) Then
Begin
Result:=AllFunctionMsg[i].MsgContent;
Exit;
End;
End;
End;
}
//读取功能消息记录
Function SearchMsg(Title:String;GateID:Integer):TStrings;
Var
i,Ilow,ihigh:Integer;
Info:String;
List:TStrings;
Begin
List:=TStringList.Create;List.Clear;
Title:=UpperCase(Title);
ilow:=Low(AllFunctionMsg);
iHigh:=High(AllFunctionMsg);
For i:=iLow to iHigh Do
Begin
If (AllFunctionMsg[i].Title=Title) And (AllFunctionMsg[i].GateID=GateID) Then
Begin
Info:=Trim(AllFunctionMsg[i].MsgContent);
If Info<>'' Then List.Add(Info);
End
Else If (List.Count>0) And (AllFunctionMsg[i].GateID>0) Then Break;
If (AllFunctionMsg[i].GateID<0) And (AllFunctionMsg[i].Title=Title) Then
Begin
Info:=Trim(AllFunctionMsg[i].MsgContent);
If Info<>'' Then List.Add(Info);
End
Else If (List.Count>0) And (AllFunctionMsg[i].GateID<0) Then Break;
End;
Result:=List;
End;
//读取功能消息记录
Function SearchMsg(Title:String;GateID:Integer;OldPattern,NewPattern:Array Of String):TStrings;
Var
i,Ilow,ihigh:Integer;
Info:String;
List:TStrings;
Begin
List:=TStringList.Create;List.Clear;
Title:=UpperCase(Title);
ilow:=Low(AllFunctionMsg);
iHigh:=High(AllFunctionMsg);
For i:=iLow to iHigh Do
Begin
If (AllFunctionMsg[i].Title=Title) And (AllFunctionMsg[i].GateID=GateID) Then
Begin
Info:=Trim(AllFunctionMsg[i].MsgContent);
If Info<>'' Then
Begin
Info:=MulReplace(Info,OldPattern,NewPattern);
List.Add(Info);
End;
End
Else If (List.Count>0) And (AllFunctionMsg[i].GateID>0) Then Break;
If (AllFunctionMsg[i].GateID<0) And (AllFunctionMsg[i].Title=Title) Then
Begin
Info:=Trim(AllFunctionMsg[i].MsgContent);
If Info<>'' Then
Begin
Info:=MulReplace(Info,OldPattern,NewPattern);
List.Add(Info);
End;
End
Else If (List.Count>0) And (AllFunctionMsg[i].GateID<0) Then Break;
End;
Result:=List;
End;
//读取功能消息记录
Function SearchMsg(Title:String;ProviderID,GateID:Integer):TStrings;
Var
i,Ilow,ihigh:Integer;
Info:String;
List:TStrings;
Begin
List:=TStringList.Create;List.Clear;
Title:=UpperCase(Title);
ilow:=Low(AllProviderFunctionMsg[ProviderID]);
iHigh:=High(AllProviderFunctionMsg[ProviderID]);
For i:=iLow to iHigh Do
Begin
If (AllProviderFunctionMsg[ProviderID][i].Title=Title) And (AllProviderFunctionMsg[ProviderID][i].GateID=GateID) Then
Begin
Info:=Trim(AllProviderFunctionMsg[ProviderID][i].MsgContent);
If Info<>'' Then List.Add(Info);
End
Else If (List.Count>0) And (AllProviderFunctionMsg[ProviderID][i].GateID>0) Then Break;
If (AllProviderFunctionMsg[ProviderID][i].GateID<0) And (AllProviderFunctionMsg[ProviderID][i].Title=Title) Then
Begin
Info:=Trim(AllProviderFunctionMsg[ProviderID][i].MsgContent);
If Info<>'' Then List.Add(Info);
End
Else If (List.Count>0) And (AllProviderFunctionMsg[ProviderID][i].GateID<0) Then Break;
End;
Result:=List;
End;
//读取功能消息记录
Function SearchMsg(Title:String;ProviderID,GateID:Integer;OldPattern,NewPattern:Array Of String):TStrings;
Var
i,Ilow,ihigh:Integer;
Info:String;
List:TStrings;
Begin
List:=TStringList.Create;List.Clear;
Title:=UpperCase(Title);
ilow:=Low(AllProviderFunctionMsg[ProviderID]);
iHigh:=High(AllProviderFunctionMsg[ProviderID]);
For i:=iLow to iHigh Do
Begin
If (AllProviderFunctionMsg[ProviderID][i].Title=Title) And (AllProviderFunctionMsg[ProviderID][i].GateID=GateID) Then
Begin
Info:=Trim(AllProviderFunctionMsg[ProviderID][i].MsgContent);
If Info<>'' Then
Begin
Info:=MulReplace(Info,OldPattern,NewPattern);
List.Add(Info);
End;
End
Else If (List.Count>0) And (AllProviderFunctionMsg[ProviderID][i].GateID>0) Then Break;
If (AllProviderFunctionMsg[ProviderID][i].GateID<0) And (AllProviderFunctionMsg[ProviderID][i].Title=Title) Then
Begin
Info:=Trim(AllProviderFunctionMsg[ProviderID][i].MsgContent);
If Info<>'' Then
Begin
Info:=MulReplace(Info,OldPattern,NewPattern);
List.Add(Info);
End;
End
Else If (List.Count>0) And (AllProviderFunctionMsg[ProviderID][i].GateID<0) Then Break;
End;
Result:=List;
End;
//初始化系统
Procedure InitSystem;
Var
DataBaseName,UserName,Password:String;
RegisterNumberIndex,ProviderIDIndex:Integer;
Begin
MakeNull(IndealQueueRec);
StopReconnectFlag:=True;//停止重连标志
ConnectServerFlag:=True;//是否要重连标志
ConnectDataBaseFlag:=False;// 连接数据库状态标志
AllDialCodeInfoReadFlag:=False;//点拨信息读取标志
AllFunctionMsgReadFlag:=False;//功能信息读取标志
For ProviderIDIndex:=0 To 3 Do
ReadAllProviderFunctionMsgFlag[ProviderIDIndex]:=False;//读取所有运营商功能消息标志
MsgID:=0;
ServerIP:=ReadConfig(IniFileName,'Server','SmsIP');//短信IP地址
ServerPort:=ReadConfig(IniFileName,'Server','SmsPort');//短信端口
DataBaseName:=ReadConfig(IniFileName,'Database','DataBaseName');//数据库名称
UserName:=ReadConfig(IniFileName,'Database','UserName');//数据库用户名称
Password:=ReadConfig(IniFileName,'Database','Password');//数据库密码
DBConnectionString:=GetDBConnectionString(DataBaseName,UserName,PassWord);//业务运行数据库连接串
DataBaseName:=ReadConfig(IniFileName,'LogDatabase','DataBaseName');//数据库名称
UserName:=ReadConfig(IniFileName,'LogDatabase','UserName');//数据库用户名称
Password:=ReadConfig(IniFileName,'LogDatabase','Password');//数据库密码
LogDBConnectionString:=GetDBConnectionString(DataBaseName,UserName,PassWord);//日志数据库连接串
DialCodeInfoTableName:=ReadConfig(IniFileName,'Config','DialCodeInfoTableName');//点拨信息表名称
FunctionMsgTableName:=ReadConfig(IniFileName,'Config','FunctionMsgTableName');//功能信息表名称
For ProviderIDIndex:=0 To 3 Do
Begin
Try
ReadAllProviderFunctionMsgFlag[ProviderIDIndex]:=StrToBool(ReadConfig(IniFileName,'Other','ReadAllProviderFunctionMsgFlag'+IntToStr(ProviderIDIndex)));Except End;//功能信息表名称
If ReadAllProviderFunctionMsgFlag[ProviderIDIndex]=True Then
Try ProviderFunctionMsgTableName[ProviderIDIndex]:=ReadConfig(IniFileName,'Other','ProviderFunctionMsgTableName'+IntToStr(ProviderIDIndex));Except End;//功能信息表名称
End;
DelTableName:=ReadConfig(IniFileName,'Config','DelTableName');//上行日志表名称
SubTableName:=ReadConfig(IniFileName,'Config','SubTableName');//下行日志表名称
SysCaption:=ReadConfig(IniFileName,'Config','SysCaption');//系统标题
SysProgramName:=ReadConfig(IniFileName,'Config','SysProgramName');//系统程序名称
Try RegisterNumberAmount:=StrToInt(ReadConfig(IniFileName,'Config','RegisterNumberAmount'));Except End;//注册业务代码数目
SetLength(RegisterNumber,RegisterNumberAmount);
For RegisterNumberIndex:=Low(RegisterNumber) To High(RegisterNumber) Do
RegisterNumber[RegisterNumberIndex]:=ReadConfig(IniFileName,'Config','RegisterNumber'+IntToStr(RegisterNumberIndex));//注册业务代码
ProviderName:=ReadConfig(IniFileName,'Config','ProviderName');//企业代码(如101097797)
ProviderID:=ReadConfig(IniFileName,'Config','ProviderID');//运营商ID号(如1是连通)
Try SMType:=StrToInt(ReadConfig(IniFileName,'Config','SMType'));Except End;//短信类型(为0是数字拨号、1是短信编码)
Try ProviderChargeType:=StrToInt(ReadConfig(IniFileName,'Config','ProviderChargeType'));Except End;//运营商收费类型(为1是直接收费、0是非直接收费)
Try MaxConnectErrNum:=StrToInt(ReadConfig(IniFileName,'Config','MaxConnectErrNum'));Except End;//短信网关最大重连次数
Try MaxDBErrNum:=StrToInt(ReadConfig(IniFileName,'Config','MaxDBErrNum'));Except End;//数据库最大重连次数
Try AutoCloseFlag:=StrToBool(ReadConfig(IniFileName,'Config','AutoCloseFlag'));Except End;//自动关闭程序标志(1为True,0为False)
Try ReconnectInterval:=StrToInt(ReadConfig(IniFileName,'Config','ReconnectInterval'));Except End;//定时重连时间(如5000是5秒)
//短信群发表名称(0-移动梦网1-联通点信2-联通在信3-电信)
SmsMtSendInfoTableName[0]:=ReadConfig(IniFileName,'Other','SmsMtSendInfoTableName0');
SmsMtSendInfoTableName[1]:=ReadConfig(IniFileName,'Other','SmsMtSendInfoTableName1');
SmsMtSendInfoTableName[2]:=ReadConfig(IniFileName,'Other','SmsMtSendInfoTableName2');
SmsMtSendInfoTableName[3]:=ReadConfig(IniFileName,'Other','SmsMtSendInfoTableName3');
//短信群发序列名称(0-移动梦网1-联通点信2-联通在信3-电信)
MtSendSeq[0]:=ReadConfig(IniFileName,'Other','MtSendSeq0');
MtSendSeq[1]:=ReadConfig(IniFileName,'Other','MtSendSeq1');
MtSendSeq[2]:=ReadConfig(IniFileName,'Other','MtSendSeq2');
MtSendSeq[3]:=ReadConfig(IniFileName,'Other','MtSendSeq3');
DBADOConnection:=TADOConnection.Create(nil);//业务运行数据库ADO连接
DBADOConnection.LoginPrompt:=False;
DBADOConnection.Connected:=False;
LOGDBADOConnection:=TADOConnection.Create(nil);//日志数据库ADO连接
LOGDBADOConnection.LoginPrompt:=False;
LOGDBADOConnection.Connected:=False;
End;
//刷新系统配置
Procedure RefreshSystemSet;
Var
RegisterNumberIndex,ProviderIDIndex:Integer;
DataBaseName,UserName,Password:String;
Begin
ConnectServerFlag:=True;//是否要重连标志
ConnectDataBaseFlag:=False;// 连接数据库状态标志
AllDialCodeInfoReadFlag:=False;//点拨信息读取标志
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -