Пример #1
0
 public SFReturnCode ProcessRequest(HttpListenerContext context)
 {
     UrlHelper urlHelper = new UrlHelper(context.Request.Url);
     CommandResult parseResult = urlHelper.ParseResult;
     SFReturnCode result;
     if (urlHelper.ParseResult == CommandResult.Success)
     {
         try
         {
             this._scriptEngineer.ExecuteScript(urlHelper.ScriptName, urlHelper.Parameters);
             result = new SFReturnCode(1, EnumHelper.GetEnumDescription(CommandResult.Success));
             return result;
         }
         catch (FileNotFoundException var_2_5D)
         {
             result = new SFReturnCode(5, EnumHelper.GetEnumDescription(CommandResult.NoExistsMethod));
             return result;
         }
         catch (TimeoutException var_3_74)
         {
             result = new SFReturnCode(9, EnumHelper.GetEnumDescription(CommandResult.DoFunctionTooLongTimeProtect));
             return result;
         }
         catch (SFReturnCode sFReturnCode)
         {
             result = sFReturnCode;
             return result;
         }
         catch (Exception var_5_96)
         {
             result = new SFReturnCode(7, EnumHelper.GetEnumDescription(CommandResult.ExcuteFunctionFailed));
             return result;
         }
     }
     result = new SFReturnCode((int)parseResult, EnumHelper.GetEnumDescription(parseResult));
     return result;
 }
Пример #2
0
 public byte[] CreateReturnResult(HttpListenerContext context, SFReturnCode result)
 {
     string s = string.Format("msg={0}", result.Message);
     return Encoding.UTF8.GetBytes(s);
 }
Пример #3
0
        /// <summary>
        /// 执行文件
        /// </summary>
        /// <param name="luaHelper"></param>
        /// <param name="luaFileName"></param>
        private void ThreadExecuteFile(LuaApiRegister luaHelper, string luaFileName)
        {
            int num = 0;
               try
               {
               num = int.Parse(Config.Items["Protector"]);
               }
               catch
               {

               }

               //执行文件线程
            _doFileThread = new Thread(new ThreadStart(()=>
                {
                    try
                    {
                        _throwMessage = "";
                        _returnCode = null;
                        luaHelper.ExecuteFile(luaFileName);
                    }
                    catch (ThreadAbortException var_0_33)
                    {
                        Logger.Info("脚本引擎主动中止线程.");
                    }
                    catch (SFReturnCode returnCode)
                    {
                        _returnCode = returnCode;
                    }
                    catch (Exception ex)
                    {
                        _throwMessage = ex.Message;
                    }

                }));

               this._doFileThread.IsBackground = true;
               this._doFileThread.Start();
               ThreadProtecter.getInstance(num).Start(_doFileThread);
               if (ThreadProtecter.getInstance(num).IsTimeout)
               {
               Logger.Error("自动关闭脚本");
               throw new TimeoutException("自动关闭脚本");
               }

               if (this._returnCode != null)
               {
               throw this._returnCode;
               }

               if (string.IsNullOrEmpty(this._throwMessage))
               {
               Logger.Info("执行完毕:" + luaFileName);
               }
               else
               {
               if (!string.IsNullOrEmpty(this._throwMessage))
               {
                   Logger.Info(this._throwMessage);
               }
               }
        }