Lua in c#

Please post here if you have problems in using Wing FTP Server.

Lua in c#

Postby Curtis Newton » Wed Sep 07, 2011 6:43 am

Hi,

I try to convert the example from http://www.wftpserver.com/help/ftpserver/lua_language.htm" rel="nofollow" rel="nofollow into c# with no success:

Code: Select all
public void get_onlinedomains()
      {
         string strURL = "http://127.0.0.1:5466/admin_webservice.html";
         string strUrlParam = "?admin=administrator&pass=secretphrase&cmd=";
         String strLuaScript = "local nSessionCnt = 0 " +
                       "for _,domain in pairs(c_GetDomainList()) do " +
                       " nSessionCnt = nSessionCnt + c_GetSessionCount(domain) " +
                       "end " +
                       "print(nSessionCnt)";

         string strLuaScriptDec = System.Web.HttpUtility.UrlEncode(strLuaScript);

         
         WebRequest myWebRequest = WebRequest.Create(strURL+strUrlParam+strLuaScriptDec); 

            WebResponse myWebResponse = myWebRequest.GetResponse(); 

            myWebResponse.Close();
      }


I do not see any result. What am I missing?


C.
Curtis Newton
 
posts 7
 
joined Mon Aug 15, 2011 6:55 pm

Re: Lua in c#

Postby Curtis Newton » Wed Sep 07, 2011 7:10 am

Code: Select all
public void get_onlinedomains()
      {
         string strURL = "http://127.0.0.1:5466/admin_webservice.html";
         string strUrlParam = "?admin=administrator&pass=secrepphrase&cmd=";
         String strLuaScript = "local nSessionCnt = 0 " +
                       "for _,domain in pairs(c_GetDomainList()) do " +
                       " nSessionCnt = nSessionCnt + c_GetSessionCount(domain) " +
                       "end " +
                       "print(nSessionCnt)";

         string strLuaScriptDec = Uri.EscapeDataString(strLuaScript);
      
         WebRequest myWebRequest = WebRequest.Create(strURL+strUrlParam+strLuaScriptDec); 

            WebResponse myWebResponse = myWebRequest.GetResponse();

         Stream dataStream = myWebResponse.GetResponseStream();

         StreamReader reader = new StreamReader(dataStream);

         string responseFromServer = reader.ReadToEnd();

         reader.Close();
         dataStream.Close();
            myWebResponse.Close();
      }


did it!
Curtis Newton
 
posts 7
 
joined Mon Aug 15, 2011 6:55 pm


Return to Support

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron