Показать сообщение отдельно
  #21  
Старый 21.04.2013, 15:23
darchken darchken вне форума
Прохожий
 
Регистрация: 31.03.2013
Сообщения: 29
Версия Delphi: Delphi 7
Репутация: 10
По умолчанию

Код:
     if (ovlan {and nvlan and vpi} > 0) and (nvlan > 0) and (vpi > 0) then begin
        if not idtelnet1.Connected then begin
          idtelnet1.Connect;
          for i:=1 to length(login) do idtelnet1.SendCh(login[i]);
          idtelnet1.SendCh(#13);
          for i:=1 to length(pass) do idtelnet1.SendCh(pass[i]);
          idtelnet1.SendCh(#13);
        end;  //if not
        if checkbox3.Checked then begin
          com1:='configure vlan id '+ edit4.Text + ' name ' + edit4.Text + ' mode residential-bridge' + #13 + 'exit all' + #13;
          for i:=1 to length(com1) do idtelnet1.SendCh(com1[i]);
          com2:='configure vlan shub id '+ edit4.Text + ' mode residential-bridge' + #13 + 'exit all' + #13;
          for i:=1 to length(com2) do idtelnet1.SendCh(com2[i]);
          com3:='configure vlan shub id '+ edit4.Text + ' egress-port lt:1/1/[4...19]' + #13;
          for i:=1 to length(com3) do idtelnet1.SendCh(com3[i]);
          com4:='configure vlan shub id '+ edit4.Text + ' egress-port lt:1/1/[1...8]' + #13;
          for i:=1 to length(com4) do idtelnet1.SendCh(com4[i]);
          com5:='configure vlan shub id '+ edit4.Text +  ' egress-port lt:1/1/[12...19]' + #13;
          for i:=1 to length(com5) do idtelnet1.SendCh(com5[i]);
          com6:='configure vlan shub id '+ edit4.Text + ' egress-port network:0' + #13;
          for i:=1 to length(com6) do idtelnet1.SendCh(com6[i]);
          com7:='configure vlan shub id '+ edit4.Text + ' egress-port network:1' + #13;
          for i:=1 to length(com7) do idtelnet1.SendCh(com7[i]);
          com8:='configure vlan shub id '+ edit4.Text + ' egress-port network:2' + #13;
          for i:=1 to length(com8) do idtelnet1.SendCh(com8[i]);
          com9:='configure vlan shub id '+ edit4.Text + ' egress-port network:3' + #13 + 'exit all' + #13;
          for i:=1 to length(com9) do idtelnet1.SendCh(com9[i]);
        end;// if checkbox3
        com10:='configure bridge port 1/1/' + Edit1.Text + '/' + Edit2.text +':0:' + Edit6.text + ' no pvid' + #13 + 'exit all' + #13;
          for i:=1 to length(com10) do idtelnet1.SendCh(com10[i]);
        com11:='configure bridge port 1/1/' + Edit1.Text + '/' + Edit2.text +':0:' + Edit6.text + ' no vlan-id ' + Edit3.text + #13 + 'exit all' + #13;
          for i:=1 to length(com11) do idtelnet1.SendCh(com11[i]);
        com12:='configure bridge port 1/1/' + Edit1.Text + '/' + Edit2.text + ':0:' + Edit6.text + ' vlan-id ' + Edit4.text + #13 + 'exit all' + #13;
          for i:=1 to length(com12) do idtelnet1.SendCh(com12[i]);
        com13:='configure bridge port 1/1/' + Edit1.Text + '/' + Edit2.text +':0:' + Edit6.text + ' pvid ' + Edit4.text + #13 + 'exit all' + #13;
          for i:=1 to length(com13) do idtelnet1.SendCh(com13[i]);
        if prof<>199 then begin
        cmd0:='info configure bridge port 1/1/' + Edit1.Text + '/' + Edit2.Text + ':0:' + Edit6.Text + ' flat' + #13;
          for i:=1 to length(cmd0) do idtelnet1.SendCh(cmd0[i]);
        com14:='configure xdsl line 1/1/'+ Edit1.Text +'/'+ Edit2.Text +' service-profile ' + IntToStr(prof) + #13 + 'exit all' + #13;
          for i:=1 to length(com14) do idtelnet1.SendCh(com14[i]);
        end; //if prof<>
        if checkbox1.Checked then
        begin
          com15:='configure atm pvc 1/1/' + Edit1.Text +'/'+ Edit2.Text +':0:'+ Edit6.Text +' admin-down' + #13 + 'exit all' + #13;
          for i:=1 to length(com15) do idtelnet1.SendCh(com15[i]);
        end;
        if checkbox2.Checked then
        begin
          com15:='configure xdsl line 1/1/' + Edit1.Text +'/'+ Edit2.Text +' admin-up' + #13 + 'exit all' + #13;
          com16:='configure atm pvc 1/1/' + Edit1.Text +'/'+ Edit2.Text+ ':0:'+ Edit6.Text +' no admin-down' + #13 + 'exit all' + #13;
          for i:=1 to length(com15) do idtelnet1.SendCh(com15[i]);
          for i:=1 to length(com16) do idtelnet1.SendCh(com16[i]);
        end;
        com17:='logout' + #13;
        //for j:=1 to 20 do
        for i:=1 to length(com17) do idtelnet1.SendCh(com17[i]);
        memo1.Lines.Add('******************************************************************************************************');
        memo1.Lines.Add(combobox1.Text + '-àëêàòåëü, ñëîò-' + Edit1.Text + ' ïîðò-' + Edit2.Text + ' âëàí-' + Edit4.Text );
        memo1.Lines.Add('******************************************************************************************************');
      end //fi ovlan
      else //if ovlan
      if prof >= 200 then begin
      cmd0:='info configure xdsl line 1/1/' + Edit1.Text + '/' + Edit2.Text + ' | match exact:service' + #13;
      for i:=1 to length(cmd0) do idtelnet1.SendCh(cmd0[i]);
      cmd:='info configure bridge port 1/1/' + Edit1.Text + '/' + Edit2.Text + ':0:' + Edit6.Text + ' | match exact:vlan-id' + #13;
      for i:=1 to length(cmd) do idtelnet1.SendCh(cmd[i]);
        com1:='configure xdsl line 1/1/'+ Edit1.Text +'/'+ Edit2.Text +' service-profile ' + IntToStr(prof) + #13 + 'exit all'  + #13;
        for i:=1 to length(com1) do idtelnet1.SendCh(com1[i]);
        if checkbox1.Checked then begin
            com2:='configure atm pvc 1/1/' + Edit1.Text +'/'+ Edit2.Text+ ':0:'+ Edit6.Text +' admin-down' + #13 + 'exit all'  + #13;
            for i:=1 to length(com2) do idtelnet1.SendCh(com2[i]);
        end; //if checkbox1
        if checkbox2.Checked then begin
            com2:='configure xdsl line 1/1/' + Edit1.Text +'/'+ Edit2.Text +' admin-up' + #13 + 'exit all'  + #13;
            com3:='configure atm pvc 1/1/' + Edit1.Text +'/'+ Edit2.Text+ ':0:'+ Edit6.Text +' no admin-down' + #13 + 'exit all'  + #13;
            for i:=1 to length(com2) do idtelnet1.SendCh(com2[i]);
            for i:=1 to length(com3) do idtelnet1.SendCh(com3[i]);
        end; //if checkbox2
      end  //if prof
      else //if prof
        begin
        if checkbox1.Checked then begin
            com2:='configure atm pvc 1/1/' + Edit1.Text +'/'+ Edit2.Text+ ':0:'+ Edit6.Text +' admin-down' + #13 + 'exit all'  + #13;
            for i:=1 to length(com2) do idtelnet1.SendCh(com2[i]);
        end; //if checkbox1
        if checkbox2.Checked then begin
            com2:='configure xdsl line 1/1/' + Edit1.Text +'/'+ Edit2.Text +' admin-up' + #13 + 'exit all'  + #13;
            com3:='configure atm pvc 1/1/' + Edit1.Text +'/'+ Edit2.Text+ ':0:'+ Edit6.Text +' no admin-down' + #13 + 'exit all'  + #13;
            for i:=1 to length(com2) do idtelnet1.SendCh(com2[i]);
            for i:=1 to length(com3) do idtelnet1.SendCh(com3[i]);
        end; //if checkbox2
        end;
      com17:='logout' + #13;
      for i:=1 to length(com17) do idtelnet1.SendCh(com17[i]);
    end
    else showmessage('Íå äîñòàòî÷íî äàííûõ!!');
  end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if idtelnet1.Connected then idtelnet1.Disconnect;
end;
end.
И еще могли бы посмотреть что можно было бы улучшить в коде, какие нибудь финты. Рекомендованные не применил по причине того что некоторые команды должен выполнять при определенных условии, поэтому оставил так как есть.
Ответить с цитированием