Exemplo n.º 1
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     bool sp = true;
     if (params_Renamed != null && params_Renamed.Length >= 2)
     {
         String val = params_Renamed[0].StringValue;
         if (val.Equals("off"))
         {
             // turn off spooling
             String name = params_Renamed[1].StringValue;
             TextWriter writer = engine.removePrintWriter(name);
             if (writer != null)
             {
                 writer.Flush();
                 writer.Close();
             }
         }
         else
         {
             // turn on spooling
             // we expected a file name
             String spname = params_Renamed[0].StringValue;
             String fname = params_Renamed[1].StringValue;
             try
             {
                 FileInfo nfile = new FileInfo(fname);
                 nfile.Create();
                 FileStream fos = new FileStream(nfile.FullName, FileMode.Create);
                 StreamWriter writer = new StreamWriter(fos);
                 engine.addPrintWriter(spname, writer);
             }
             catch (FileNotFoundException e)
             {
                 // we should report it
                 sp = false;
             }
             catch (IOException e)
             {
                 sp = false;
             }
         }
     }
     else
     {
         sp = false;
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, sp);
     ret.addReturnValue(rv);
     return ret;
 }