Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 3.94 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to reconnect modem in C#? (Actiontec PK5000)
  2. function act_discon()
  3. {
  4.     if( parent == null || parent.frames[1] == null)
  5.         return;
  6.  
  7.     if( iConnect == "Not Connected" ) {
  8.         pop_up("Already Disconnected!",0);
  9.         return;
  10.     }
  11.  
  12.     pop_up("You are about to disconnect from the Internet.",2, disconn_from_internet);
  13. /*
  14.     if( sta_type=="dhcpc" )
  15.     {
  16.         parent.frames[1].window.document.status_hide.elements[3].disabled = false;
  17.         parent.frames[1].window.document.status_hide.elements[3].name = "connection0:dhcpc:command/release";
  18.     }
  19.     else if( sta_type=="asis" ) {
  20.         parent.frames[1].window.document.status_hide.elements[2].disabled = false;
  21.         parent.frames[1].window.document.status_hide.elements[3].disabled = false;
  22.         parent.frames[1].window.document.status_hide.elements[3].name = "encaps0:pppoa:command/stop";
  23.     }
  24.     else if( sta_type=="pppoe" ) {
  25.         parent.frames[1].window.document.status_hide.elements[2].disabled = false;
  26.         parent.frames[1].window.document.status_hide.elements[3].disabled = false;
  27.         parent.frames[1].window.document.status_hide.elements[3].name = "connection0:pppoe:command/stop";
  28.     }
  29.     parent.frames[1].window.document.status_hide.elements[1].value = "0";
  30.     parent.frames[1].window.document.status_hide.method = "POST";
  31.     parent.frames[1].window.document.status_hide.submit();
  32. */  
  33. }
  34.        
  35. function disconn_from_internet()
  36. {
  37.     if( sta_type=="dhcpc" )
  38.     {
  39.         parent.frames[1].window.document.status_hide.elements[3].disabled = false;
  40.         parent.frames[1].window.document.status_hide.elements[3].name = "connection0:dhcpc:command/release";
  41.     }
  42.     else if( sta_type=="asis" ) {
  43.         parent.frames[1].window.document.status_hide.elements[2].disabled = false;
  44.         parent.frames[1].window.document.status_hide.elements[3].disabled = false;
  45.         parent.frames[1].window.document.status_hide.elements[3].name = "encaps0:pppoa:command/stop";
  46.     }
  47.     else if( sta_type=="pppoe" ) {
  48.         parent.frames[1].window.document.status_hide.elements[2].disabled = false;
  49.         parent.frames[1].window.document.status_hide.elements[3].disabled = false;
  50.         parent.frames[1].window.document.status_hide.elements[3].name = "connection0:pppoe:command/stop";
  51.     }
  52.     parent.frames[1].window.document.status_hide.elements[1].value = "0";
  53.     parent.frames[1].window.document.status_hide.method = "POST";
  54.     parent.frames[1].window.document.status_hide.submit();
  55. }
  56.        
  57. <form    method="POST"  name="status_hide"  action="/cgi-bin/webcm" target="_self">
  58.     <input type="hidden" name="getpage"     value="../html/status_hide.html">
  59.     <input type="hidden" name="var:opt" value="1">
  60.     <input type="hidden" name="logic:command/kill_ppp" value="" disabled>
  61.  
  62.     <input type="hidden" name="cmd" value="1" disabled>
  63.     <input type="hidden" name="Conn_pppoa"     value="" disabled>
  64.  
  65.     <input type="hidden" name="Conn_pppoe"     value="Connected" disabled>
  66.     <input type="hidden" name="Conn_dhcpc"     value="" disabled>
  67.   </form>
  68.        
  69. private void button4_Click(object sender, EventArgs e)
  70.         {
  71.             try
  72.             {
  73.                 var uriString = "http://192.168.0.1/cgi-bin/webcm";
  74.                 WebClient myWebClient = new WebClient();
  75.                 NameValueCollection myNameValueCollection = new NameValueCollection();
  76.                 myNameValueCollection.Add("getpage", "../html/status_hide.html");
  77.                 myNameValueCollection.Add("var:opt", "0");
  78.                 myNameValueCollection.Add("logic:command/kill_ppp", "");
  79.                 myNameValueCollection.Add("encaps0:pppoa:command/stop", "1");
  80.                 byte[] responseArray = myWebClient.UploadValues(uriString, myNameValueCollection);
  81.                 log("Failed to update mail date creation, function UpdateMailDateCreation. MySQL error:" + Encoding.ASCII.GetString(responseArray));
  82.             }
  83.             catch (Exception ex)
  84.             {
  85.                 log(ex.ToString());
  86.             }
  87.         }