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

📄 main_.pas

📁 以可视的方式画IVR语音导航的流程,并把流程做为源文件保存起来
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    IVREventData := TList.Create();
    ValueStringList := TStringList.Create();
    SelectIVR := TSelectIVR.Create(Self);
    BoxList := TList.Create();

    NodeList := TList.Create();
    NodeList.Add(nil);

    fcNodeList := TList.Create();


    ActiveBox := MainBox;
    ActiveTree := IVRPointTree;
    BoxList.Add(ActiveBox);


    //2002.9.24
    {
    ComSrocllBox.Items.Add(IntToStr(ActiveBox.Tag)+'[主流程]');
    ComSrocllBox.ItemIndex := ComSrocllBox.Items.Count -1 ;
    }

    // 2002.09.24
      SetfcTreeCom(nil,'主流程');
    // 2002.09.24


    if not(FileExists(MainProgramPath + 'Save.Dat')) then
    begin
        clMsgBox('必须的系统文件不存在,软件不能运行!', MB_ICONERROR);
        Application.Terminate();
        Exit;
    end;

    //寻找编译引擎
    FlashForm.AddStatusText('搜索编译引擎');
    if FindFirst(MainProgramPath + 'Engine\*.*', faAnyFile, FindFileDat) = 0 then
    begin
        s := ExtractFileExt(FindFileDat.Name);
        if (StrUpper(PChar(s)) = 'DLL') then
        begin
            s := FindFileDat.Name;
            dllHandle := LoadLibrary(PChar(s));
            @GetVersion := GetProcAddress(dllHandle, PChar('GetVersion'));
            if @GetVersion <> nil then
            begin
                GetVersion(@dllVer);
                EngineList.Add(s);
                EngineMemo.Add(dllVer.EngineMemo);
                tmpMenuItem := TMenuItem.Create(Self);
                tmpMenuItem.Caption := dllVer.EngineName;
                tmpMenuItem.Hint := dllVer.EngineHint;
                tmpMenuItem.Name := 'Engine' + IntToStr(EngineList.Count - 1);
                tmpMenuItem.OnClick := BuildClick;
                EnginePopup.Items.Add(tmpMenuItem);
            end;
            @GetVersion := nil;
            FreeLibrary(dllHandle);
        end;
        while FindNext(FindFileDat) = 0 do
        begin
            s := ExtractFileExt(FindFileDat.Name);
            if (StrUpper(PChar(s)) = '.DLL') then
            begin
                s := MainProgramPath + 'Engine\' + FindFileDat.Name;
                dllHandle := LoadLibrary(PChar(s));
                @GetVersion := GetProcAddress(dllHandle, PChar('GetVersion'));
                if @GetVersion <> nil then
                begin
                    GetVersion(@dllVer);
                    EngineList.Add(s);
                    EngineMemo.Add(dllVer.EngineMemo);
                    tmpMenuItem := TMenuItem.Create(Self);
                    tmpMenuItem.Caption := dllVer.EngineName;
                    tmpMenuItem.Hint := dllVer.EngineHint;
                    tmpMenuItem.Name := 'Engine' + IntToStr(EngineList.Count - 1);
                    tmpMenuItem.OnClick := BuildClick;
                    EnginePopup.Items.Add(tmpMenuItem);
                end;
                @GetVersion := nil;
                FreeLibrary(dllHandle);
            end;
        end;
        FindClose(FindFileDat);
    end;
    if EngineList.Count <= 0 then
    begin
        clMsgBox('系统找不到任何编译引擎,拒绝运行!', MB_ICONERROR);
        Application.Terminate();
        Exit;
    end;

    with TIniFile.Create(MainProgramPath + 'Config.ini') do
    begin
        DefaultWrite := ReadString('Gernal', 'User', '未注册用户');
        XPStyle := ReadBool('Gernal', 'XP-Style', false);
        DefaultWidth := ReadInteger('Box', 'Width', 2000);
        DefaultHeight := ReadInteger('Box', 'Height', 2000);
        DefaultEngine := ReadInteger('Gernal', 'Engine', 0);
        StartCaption := ReadString('Start', 'Caption', '项目的开端');
        StartType := ReadInteger('Start', 'iType', 1);
        StartContent := ReadInteger('Start', 'iContent', 0);
        IVRLineColor := StringToColor(ReadString('Color', 'Line', '$009A813F'));
        IVRPointColor := StringToColor(ReadString('Color', 'IVR', '$008400FF'));
        IVREventColor := StringToColor(ReadString('Color', 'Event', '$00FF8200'));

        SubCaption := ReadString('SubProcess', 'SubCaption','子流程模块' );
        SubProcess := ReadInteger('SubProcess', 'SubiType', 80);
        SubiContent:= ReadInteger('SubProcess', 'SubiContent', 0);

        SubStartCaption := ReadString('SubProcess', 'SubStartCaption', '开始子流程');
        SubStartiType := ReadInteger('SubProcess', 'SubStartiType',80 );
        SubStartiContent := ReadInteger('SubProcess', 'SubStartiContent',1 );

       SubEndCaption := ReadString('SubProcess', 'SubEndCaption', '结束子流程');
       SubEndiType := ReadInteger('SubProcess', 'SubEndiType', 80);
       SubEndiContent := ReadInteger('SubProcess', 'SubEndiContent', 2);
       MyDelayTime := ReadInteger('Delay', 'MyDelayTime', 10);

        //读入最近打开文件
        ReOpenCount := 0;
        for i := 1 to 5 do
        begin
            s := ReadString('ReOpen', 'File' + IntToStr(i), '');
            if s <> '' then
            begin
                case i of
                1: tmpMenuItem := ReOpen1;
                2: tmpMenuItem := ReOpen2;
                3: tmpMenuItem := ReOpen3;
                4: tmpMenuItem := ReOpen4;
                5: tmpMenuItem := ReOpen5;
                else
                    tmpMenuItem := nil;
                end;
                tmpMenuItem.Caption := s;
                tmpMenuItem.Visible := True;
                Inc(ReOpenCount);
            end;
        end;
        if ReOpenCount > 0 then
            ReOpen.Enabled := True;
        Free();
    end;

    ADOConnect := TADOConnection.Create(self) ;
    ADOConnect.LoginPrompt := false ;

    with TADOQuery.Create(Self) do
    begin
      try
        FlashForm.AddStatusText('装载基本资料');
        ConnectionString := MakeConnectionString(MainProgramPath + 'ivr.dat');
        SQL.Add('select top 1 * from Detail');
        Open();
        OEM := FieldByName('OEM').AsBoolean;
        {DefaultWidth := FieldByName('Width').AsInteger;
        DefaultHeight := FieldByName('Height').AsInteger;}
        DetailOwner := FieldByName('Owner').AsString;
        DetailMemo := FieldByName('Memo').AsString;
        s := FieldByName('Message').AsString;
        if s <> '' then
            clMsgBox(s);
        Close();
        FlashForm.AddStatusText('装载IVR类别资料');
        SQL[0] := 'select * from iType order by iType';
        Open();
        MenuCount := RecordCount;
        SetLength(IVRType, MenuCount);
        SetLength(IVRTypeIndex, MenuCount);
        SetLength(IVRPointMenu, MenuCount);
        Last();
        SelectIVR.IVRType.Items.Clear();
        //生成类别按钮Toolbar
        for i := MenuCount - 1 downto 0 do
        begin
            IVRType[i] := TToolButton.Create(IVRPointTypeBar);
            IVRType[i].Caption :=FieldByName('iType').AsString +'.'+ FieldByName('Caption').AsString + '';
            IVRType[i].Hint := FieldByName('Hints').AsString;
            IVRType[i].ShowHint := true;
            IVRType[i].Parent := IVRPointTypeBar;
            IVRPointMenu[i] := TPopupMenu.Create(Self);
            IVRPointMenu[i].AutoHotkeys := maManual;
            IVRType[i].DropdownMenu := IVRPointMenu[i];
            IVRTypeIndex[i] := FieldByName('iType').AsInteger;

            tmpIVRType := SelectIVR.IVRType.Items.AddFirst(nil, IVRType[i].Caption);
            tmpIVRType.Data := Pointer(IVRTypeIndex[i] * 1000);
            Prior();
        end;
        Close();
        FlashForm.AddStatusText('装载IVR事件资料');
        SQL[0] := 'select * from iContent order by iType, iContent';
        Open();
        //为有内容的生成子菜单
        while not(Eof) do
        begin
          i := IVRiTypeToMenu(FieldByName('iType').AsInteger);
          if i >= 0 then
          begin
            tmpMenuItem := TMenuItem.Create(Self);
            tmpMenuItem.Caption := FieldByName('iType').AsString +'.'+FieldByName('iContent').AsString+'-'+ FieldByName('Caption').AsString;
            tmpMenuItem.Hint := FieldByName('Hints').AsString;
            s := IntToStr(FieldByName('iType').AsInteger);
            if Length(s) = 1 then
                s := '0' + s;
            tmpMenuItem.Name := 'IVR' + s;
            s := IntToStr(FieldByName('iContent').AsInteger);
            if Length(s) = 1 then
                s := '0' + s;
            tmpMenuItem.Name := tmpMenuItem.Name + s;
            tmpMenuItem.OnClick := IVRPointClick;
            IVRPointMenu[i].Items.Add(tmpMenuItem);

           //2002.9.26 不显示子流程的开始模块
           if (FieldByName('iType').AsInteger = SubProcess)  and  (FieldByName('iContent').AsInteger = SubStartiContent) then
                 tmpMenuItem.Visible := false ; 

           //

            for j := 0 to SelectIVR.IVRType.Items.Count - 1 do
            begin
                if Integer(SelectIVR.IVRType.Items[j].Data) div 1000 = FieldByName('iType').AsInteger then
                begin
                    tmpIVRType := SelectIVR.IVRType.Items.AddChild
                        (SelectIVR.IVRType.Items[j], tmpMenuItem.Caption);
                    tmpIVRType.Data := Pointer(FieldByName('iType').AsInteger * 1000 + FieldByName('iContent').AsInteger);
                    Break;
                end;
            end;
          end;
          Next();
        end;
        Close();
        FlashForm.AddStatusText('生成菜单选项资料');
        //为没有内容的按钮生成一个与按钮同名的子菜单
        for i := 0 to MenuCount - 1 do
        begin
            if IVRPointMenu[i].Items.Count <= 0 then
            begin
                tmpMenuItem := TMenuItem.Create(Self);
                tmpMenuItem.Caption := IVRType[i].Caption;
                tmpMenuItem.Hint := IVRType[i].Hint;
                s := IntToStr(IVRMenuToiType(i));
                if Length(s) = 1 then
                    s := '0' + s;
                tmpMenuItem.Name := 'IVR' + s + '00';
                tmpMenuItem.OnClick := IVRPointClick;
                IVRPointMenu[i].Items.Add(tmpMenuItem);

            end;
        end;

        FlashForm.AddStatusText('装载IVR属性资料');
        //读入属性
        SQL[0] := 'select * from Property order by iType,iContent,iValue';
        Open();
        while not(Eof) do
        begin
            New(tmpProperty);
            tmpProperty.iType := FieldByName('iType').AsInteger;
            tmpProperty.iContent := FieldByName('iContent').AsInteger;
            tmpProperty.Index := FieldByName('iValue').AsInteger;
            tmpProperty.Caption := FieldByName('Caption').AsString;
            tmpProperty.Must := FieldByName('Must').AsBoolean;
            i := FieldByName('PropertyType').AsInteger;
            tmpProperty.pType := IntToPropertyType(i);
            IVRPropertyData.Add(tmpProperty);
            Next();
        end;
        Close();

        FlashForm.AddStatusText('装载IVR事件资料');
        //读入事件
        SQL[0] := 'select * from Event order by iType,iContent,iValue';
        Open();
        while not(Eof) do
        begin
            New(tmpEvent);
            tmpEvent.iType := FieldByName('iType').AsInteger;
            tmpEvent.iContent := FieldByName('iContent').AsInteger;
            tmpEvent.Index := FieldByName('iValue').AsInteger;
            tmpEvent.Caption := FieldByName('Caption').AsString;
            tmpEvent.Hints := FieldByName('Hints').AsString;
            IVREventData.Add(tmpEvent);
            Next();
        end;
        Close();

        FlashForm.AddStatusText('装载IVR公共变量资料');
        //读入公共变量定义
        SQL[0] := 'select * from Define order by iType, id';
        Open();
        DefineCount := RecordCount;
        SetLength(DefineValue, DefineCount);
        i := 0;
        while not(Eof) do
        begin
            DefineValue[i].id := FieldByName('id').AsInteger;
            DefineValue[i].iType := FieldByName('iType').AsInteger;
            DefineValue[i].vcName := FieldByName('vcName').AsString;
            DefineValue[i].vcValue := '';
            DefineValue[i].vcComment := FieldByName('vcComment').AsString;
            Inc(i);
            Next();
        end;
        Close();

        FlashForm.AddStatusText('装载IVR通道变量定义');
        //读入每个通道的变量定义
        SQL[0] := 'select * from var order by cValue';
        Open();
        while not(Eof) do
        begin
            ValueStringList.Add(FieldByName('cValue').AsString);
            Next();
        end;
        Close();

        FlashForm.AddStatusText('装载资料完成,启动成功!');
        Free();
      except
        clMsgBox('读入参数错误,初始化失败!', MB_ICONERROR);
        Free();
        FlashForm.Free();
        Application.Terminate();
      end;
    end;

//    XPMenu.Active := XPStyle;
    actSetupXPStyle.Checked := not(XPStyle);
    Proc := nil;

    SelectIVREvent.IVRPoint := nil;
    DeSelectIVRPointEvent();

    Screen.Cursors[1] := LoadCursor(hInstance, 'MOVE');
    Screen.Cursors[2] := LoadCursor(hInstance, 'PUSH');
    Screen.Cursors[3] := LoadCursor(hInstance, 'LINE');
    Screen.Cursors[4] := LoadCursor(hInstance, 'ZOOMIN1');
    Screen.Cursors[5] := LoadCursor(hInstance, 'ZOOMOUT1');
    Screen.Cursors[6] := LoadCursor(hInstance, 'DOWN1');

    MainBox.Cursor := crMOVE;
    SetBuildBtnCaption();
end;

//退出的动作
procedure Tmain.actFileExitExecute(Sender: TObject);
begin
    Close();
end;

//关于我们动作
procedure Tmain.actHelpAboutExecute(Sender: TObject);
begin
    if OEM then
        MessageBox(
            main.Handle,
            PChar('OEM v' + clGetAppVersion(Application.ExeName)),
            PChar('关于我们'),
            MB_ICONINFORMATION)
    else
        CLAbout.ShowAboutForm();
end;

//退出程序事件
procedure Tmain.FormClose(Sender: TObject; var Action: TCloseAction);
var
    i: Integer;
    tmpProperty: PIVRPropertyData;
    tmpEvent: PIVREventData;
begin
    if not(clSureBoxEx('确定退出IVR Studio?')) then
    begin
        Action := caNone;
    end else begin
        for i := 0 to IVRPropertyData.Count - 1 do
        begin
            tmpProperty := IVRPropertyData[0];
            IVRPropertyData.Delete(0);
            Dispose(tmpProperty);
        end;
        IVRPropertyData.Clear();
        IVRPropertyData.Free();

        for i := 0 to IVREventData.Count - 1 do
        begin
            tmpEvent := IVREventData[0];
            IVREventData.Delete(0);
            Dispose(tmpEvent);
        end;
        IVREventData.Clear();
        IVREventData.Free();

        SelectIVR.Free();

        ValueStringList.Free();
        EngineList.Free();
        EngineMemo.Free();


    end;
end;

//增加IVR节点到画板上
function Tmain.AddIVRPoint(IVRCaption: String; iType, iContent, IDNumber,GodID: Integer): TIVRPoint;

⌨️ 快捷键说明

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