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

📄 uexpsubflow.pas

📁 以可视的方式画IVR语音导航的流程,并把流程做为源文件保存起来
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit uExpSubFlow;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls,
  DB, ADODB, StdCtrls;

type
  TFunctionRec = record
    id: integer;
    Caption: array[0..49] of Char;
    x: integer;
    y: integer;
    iid_0: integer;
    iid_1: integer;
    iid_2: integer;
    iType: integer;
    iContent: integer;
    iMode: integer;
    CsubType: array[0..19] of Char;
    Ccomment: array[0..39] of Char;

    iattr_type: array[0..19] of integer;
    cattr_content: array[0..19,0..99] of Char;

    ievent: array[0..19] of integer;
    ievent_id: array[0..19] of integer;

    FunctionID: integer;
    OldID: integer;
  end;
  PFunctionRec = ^TFunctionRec;

  TFunctionListRec = record
    id: integer;
    Caption: array[0..49] of Char;
    x: integer;
    y: integer;
    iid_0: integer;
    iid_1: integer;
    iid_2: integer;
    iType: integer;
    iContent: integer;
    iMode: integer;
    CsubType: array[0..19] of Char;
    Ccomment: array[0..39] of Char;

    iattr_type: array[0..19] of integer;
    cattr_content: array[0..19,0..99] of Char;

    ievent: array[0..19] of integer;
    ievent_id: array[0..19] of integer;

    FunctionID: integer;
    Func: array[0..49] of Char;
    FunMemo: array[0..49] of Char;
    UpDate: TDateTime;
    ParentID: integer;
    FunCheck: boolean;
    OldID: integer;
  end;
  PFunctionListRec = ^TFunctionListRec;

  TExpSubFlow = class(TComponent)
  private
    FDatabase: string;

    FunctionRecs: TList;
    FunctionListRecs: TList;

    procedure ExportSubFlowList(var iNowID: integer; iFuncID: integer);
    procedure FormatSubFlowList;
    procedure InsertToTmpTable;

    function GetIDFromFunc(iOldID, iNowID: integer): integer;

  public
    constructor Create(AOwer: TComponent); override;
    destructor Destroy; override;

    procedure ExportSubFlow(var iNowID: integer; iFuncID: integer);
  published
    property Database: string read FDatabase write FDatabase;
  end;

implementation

{ TExpSubFlow }

constructor TExpSubFlow.Create(AOwer: TComponent);
begin
  inherited;

  FunctionRecs := TList.Create;
  FunctionListRecs := TList.Create;

end;

destructor TExpSubFlow.Destroy;
begin
  FunctionRecs.Free;
  FunctionListRecs.Free;


  inherited;
end;

procedure TExpSubFlow.ExportSubFlow(var iNowID: integer; iFuncID: integer);
begin
  ExportSubFlowList(iNowID, iFuncID);
  FormatSubFlowList;
  InsertToTmpTable;
end;

function TExpSubFlow.GetIDFromFunc(iOldID, iNowID: integer): integer;
var
  i: integer;
  bFind: boolean;
  FunctionRec: PFunctionRec;
begin
  bFind := False;

  for i := 0 to FunctionRecs.Count - 1 do
  begin
    FunctionRec := FunctionRecs[i];
    if FunctionRec.OldID = iOldID then
    begin
      bFind := True;
      Result := FunctionRec.id;
      Break;
    end;
  end;

  if not bFind then
  begin
    Result := iNowID;
  end;
end;

procedure TExpSubFlow.ExportSubFlowList(var iNowID: integer;
  iFuncID: integer);
var
  s: string;
  ADOFun: TADOQuery;
  iID: integer;
  iFunID: integer;

  FunctionRec: PFunctionRec;
  FunctionListRec: PFunctionListRec;

  sField: string;
  i: integer;
begin
   ADOFun := TADOQuery.Create(nil);
   ADOFun.ConnectionString := FDatabase;

   s := 'select * from FunctionList where FunctionID=' + IntToStr(iFuncID);
   ADOFun.SQL.Add(s);
   ADOFun.Open;


   if not ADOFun.IsEmpty then
   begin
     new(FunctionListRec);

     with FunctionListRec^ do
     begin
       id := GetIDFromFunc(ADOFun.FieldByName('id').AsInteger,iNowID);

       StrPCopy(Caption,ADOFun.FieldByName('Caption').AsString);
       x := ADOFun.FieldByName('x').AsInteger;
       y := ADOFun.FieldByName('y').AsInteger;
       iid_0 := ADOFun.FieldByName('iid_0').AsInteger;
       iid_1 := ADOFun.FieldByName('iid_1').AsInteger;
       iid_2 := iNowID;
       iType := ADOFun.FieldByName('iType').AsInteger;
       iContent := ADOFun.FieldByName('iContent').AsInteger;
       iMode := ADOFun.FieldByName('iMode').AsInteger;
       StrPCopy(CsubType, ADOFun.FieldByName('CsubType').AsString);
       StrPCopy(Ccomment, ADOFun.FieldByName('Ccomment').AsString);

       for i := 0 to 19 do
       begin
         sField := 'iattr_' + IntToStr(i) + '_type';
         iattr_type[i] := ADOFun.FieldByName(sField).AsInteger;

         sField := 'cattr_' + IntToStr(i) + '_content';
         StrPCopy(cattr_content[i], ADOFun.FieldByName(sField).AsString);

         sField := 'ievent_' + IntToStr(i);
         ievent[i] := ADOFun.FieldByName(sField).AsInteger;

         sField := 'ievent_' + IntToStr(i) + '_id';
         ievent_id[i] := ADOFun.FieldByName(sField).AsInteger;
       end;

       FunctionID := ADOFun.FieldByName('FunctionID').AsInteger;
       StrPCopy(Func, ADOFun.FieldByName('Function').AsString);
       StrPCopy(FunMemo, ADOFun.FieldByName('FunMemo').AsString);
       UpDate := ADOFun.FieldByName('UpDate').AsDateTime;
       ParentID := ADOFun.FieldByName('ParentID').AsInteger;
       FunCheck := ADOFun.FieldByName('FunCheck').AsBoolean;
       OldID := ADOFun.FieldByName('id').AsInteger;
     end;

     FunctionListRecs.Add(FunctionListRec);

     Inc(iNowID);

     ADOFun.Close;

     s := 'select * from Function where FunctionID=' + IntToStr(iFuncID) + ' order by id';
     ADOFun.SQL.Clear;
     ADOFun.SQL.Add(s);
     ADOFun.Open;
     while not ADOFun.Eof do
     begin
       new(FunctionRec);

       with FunctionRec^ do
       begin
         id := iNowID;
         StrPCopy(Caption,ADOFun.FieldByName('Caption').AsString);
         x := ADOFun.FieldByName('x').AsInteger;
         y := ADOFun.FieldByName('y').AsInteger;
         iid_0 := ADOFun.FieldByName('iid_0').AsInteger;
         iid_1 := ADOFun.FieldByName('iid_1').AsInteger;
         iid_2 := iNowID;
         iType := ADOFun.FieldByName('iType').AsInteger;
         iContent := ADOFun.FieldByName('iContent').AsInteger;
         iMode := ADOFun.FieldByName('iMode').AsInteger;
         StrPCopy(CsubType, ADOFun.FieldByName('CsubType').AsString);
         StrPCopy(Ccomment, ADOFun.FieldByName('Ccomment').AsString);

         for i := 0 to 19 do
         begin
           sField := 'iattr_' + IntToStr(i) + '_type';
           iattr_type[i] := ADOFun.FieldByName(sField).AsInteger;

           sField := 'cattr_' + IntToStr(i) + '_content';
           StrPCopy(cattr_content[i], ADOFun.FieldByName(sField).AsString);

           sField := 'ievent_' + IntToStr(i);
           ievent[i] := ADOFun.FieldByName(sField).AsInteger;

           sField := 'ievent_' + IntToStr(i) + '_id';
           ievent_id[i] := ADOFun.FieldByName(sField).AsInteger;
         end;

         FunctionID := ADOFun.FieldByName('FunctionID').AsInteger;
         OldID := ADOFun.FieldByName('id').AsInteger;
       end;

       FunctionRecs.Add(FunctionRec);

       Inc(iNowID);

       ADOFun.Next;
     end;

     ADOFun.Close;

     s := 'select FunctionID from FunctionList where ParentID=' + IntToStr(iFuncID) + ' order by id';
     ADOFun.SQL.Clear;
     ADOFun.SQL.Add(s);
     ADOFun.Open;
     while not ADOFun.Eof do
     begin
       ExportSubFlowList(iNowID,ADOFun.FieldByName('FunctionID').AsInteger);
       ADOFun.Next;
     end;
     ADOFun.Close;
   end
   else
   begin
     ADOFun.Close;
   end;

   ADOFun.Free;
end;

procedure TExpSubFlow.FormatSubFlowList;
var
  i: integer;
  j: integer;
  k: integer;
  FunctionRec: PFunctionRec;
  FunctionListRec: PFunctionListRec;
  iID: integer;
  iOld: integer;
  sContent: string;
begin
  for i := 0 to FunctionRecs.Count - 1 do
  begin
    FunctionRec := FunctionRecs[i];
    iID := FunctionRec.id;
    iOld := FunctionRec.OldID;

    for j := 0 to FunctionRecs.Count - 1 do
    begin
      FunctionRec := FunctionRecs[j];

      with FunctionRec^ do
      begin
        for k := 0 to 19 do
        begin
          if (ievent[k] = 1) and (ievent_id[k] = iOld) then
          begin
            ievent_id[k] := iID;
          end;

          if (iType = 80) and (iContent = 0) and (iattr_type[k] = 1) then
          begin
            sContent := cattr_content[k];
            if Trim(sContent) = IntToStr(iOld) then
            begin
              sContent := IntToStr(iID);
              StrPCopy(cattr_content[k],sContent);
            end;
          end;
        end;
      end;
    end;

    for j := 0 to FunctionListRecs.Count - 1 do
    begin
      FunctionListRec := FunctionListRecs[j];

      with FunctionListRec^ do
      begin
        for k := 0 to 19 do
        begin
          if (ievent[k] = 1) and (ievent_id[k] = iOld) then
          begin
            ievent_id[k] := iID;
          end;

⌨️ 快捷键说明

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