Example #1
0
        public static void Main(string[] args)
        {
            object testFinance = CreateInstance("Finance");

            Console.WriteLine(testFinance.GetType().GetProperty("taxRate"));
            Finance testFinance2 = new Finance();

            foreach (FieldInfo FI in testFinance.GetType().GetFields())
            {
                if (FI.Name == "bankSide")
                {
                    dynamic     bankSide  = FI.GetValue(testFinance);
                    List <Bank> bankSide1 = bankSide;
                    foreach (FieldInfo BI in bankSide[0].GetType().GetFields())
                    {
                        if (BI.Name == "branchID")
                        {
                            dynamic    branchID  = BI.GetValue(bankSide1[0]);
                            List <int> branchID1 = branchID;
                            foreach (int i in branchID1)
                            {
                                Console.WriteLine(i);
                            }
                        }
                    }
                    // Console.WriteLine(test);
                }
            }
            //Console.WriteLine(myPropInfo.GetValue(testFinance2, null));

            Console.ReadKey();
        }
public class C : CI {     // user implements
    public void method(BI b)
    {
        if (b.Priority > 10 || b.Urgency > 10)
        {
            ;     // do something with BI using b
        }
        throw new NotImplementedException();
    }
Example #3
0
        public static string GenerateCheckBox(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(@"<label><input id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" type=""checkbox"" class=""ace"">");
            sb.AppendLine(@"<span class=""lbl"">" + field.FieldName + @" </span></label>");

            return sb.ToString();
        }
Example #4
0
        public override string ToString()
        {
            string AllItems = "";

            foreach (MedicalService BI in BillItemList)
            {
                AllItems += BI.ToString() + "\n";
            }
            return("Total amount : " + _totalPrice + ". Items : " + AllItems);
        }
Example #5
0
    public void GameOver()
    {
        // FPA (04/01/17): Eliminado GameAnalitics de momento.
        // GA.API.Design.NewEvent("PartidaTerminada:"+(GameplayService.networked ? "Multiplayer":"Singleplayer"), seconds, Vector3.zero);

        GeneralSounds.instance.gameOver();
        ifcPausa.instance.PauseEnabled = false;
        pendingGameOver = true;

        if (!GameplayService.networked)
        {
            BI.EndGame(ServiceLocator.Request <IGameplayService>().GetGameMode() == GameMode.Shooter ? 2 : 1, ServiceLocator.Request <IDifficultyService>().GetFase());
            //    ifcThrower.instance.showGameOver();
            setRoundCooldown(3f);
        }

        // comprobar si hay que cambiar a la camara de GAME_OVER
        if (ServiceLocator.Request <IGameplayService>().GetGameMode() == GameMode.Shooter)
        {
            // camara para lanzador
            GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.GameOver.instance;
        }
        else if (ServiceLocator.Request <IGameplayService>().GetGameMode() == GameMode.GoalKeeper && GameplayService.networked)
        {
            // camara para portero en modo duelo
            Debug.LogWarning(">>> ENTRA CAMARA DE PORTERO DUELO");
            GoalCamera.instance.stateMachine.changeState = GoalKeeperCameraStates.CamaraGameOverDueloPortero.instance;
        }

        // comprobar si se ha conseguido nuevos logros
        int           recompensaPendiente = 0;
        List <string> idsLogros           = new List <string>();

        if (PersistenciaManager.instance.CheckHayLogrosSinRecompensar(ref recompensaPendiente, ref idsLogros))
        {
            // mostrar en la barra de opciones una "exclamacion"
            cntBarraSuperior.flagNuevosLogros = true;

            // actualizar el dinero
            Interfaz.MonedasHard += recompensaPendiente;

            // actualizar el progreso de los logros para que esta alerta no se dispare mas
            PersistenciaManager.instance.SaveLogros();

            // crear los dialogos para mostrar cada uno de los logros desbloqueados
            for (int i = 0; i < idsLogros.Count; ++i)
            {
                DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.LOGRO_DESBLOQUEADO, idsLogros[i]));
            }
        }

        //(GameplayService.networked && GameplayService.IsGoalkeeper()))                         // en modo MULTIJUGADOR y si soy TIRADOR (NOTA; soy tirador si acabo jugando como portero)

        //Invoke("goToMenu", 3f);
    }
Example #6
0
 public TermNode(string tag) // builtin predicates
 {
     try
     {
         builtinId = (BI)Enum.Parse(typeof(BI), tag, false);
     }
     catch
     {
         IO.Error("Bootstrap.cs: unknown BI enum value '{0}'", tag);
     }
 }
Example #7
0
        public static string GenerateDatePicker(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            string val = string.Empty;
            DateTime dt = DateTime.MinValue;

            if (field.DataValue != null)
            {
                if (field.DataValue is DateTime)
                {
                    dt = (DateTime)field.DataValue;
                }
                else
                {
                    string dtStr = field.DataValue.ToString();
                    DateTime.TryParse(dtStr, out dt);
                }
            }

            //判断是否是空日期,空日期不需要显示
            if (dt.Year > 1900)
            {
                val = dt.ToString("MM/dd/yyyy");

                string[] formatdate = { "RFQDateIn", "RFQDateOut", "QuoteDateIn", "QuoteDateOut", "PriceDateOut" };

                if (formatdate.Contains(field.FieldName))
                {
                    val = dt.ToString("MM/dd/yyyy HH:mm:ss");
                }
            }
            else if (field.FieldName == "CustomerQuoteDate")
            {
                val = DateTime.Now.ToString("MM/dd/yyyy");

            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(@"<div class=""input-group"">
                            <input ");
            if (field.Visible == 0)
            {
                sb.AppendLine(@" disabled=""disabled""");
            }

            sb.AppendLine(@" style=""height:25px !important""  class=""form-control date-picker"" id=""" + field.FieldName + @"""  name=""" + field.FieldName + @""" Value=""" + val + @""" type=""text"" data-date-format=""mm/dd/yyyy"">
                            <span  style=""height:24px !important"" class=""input-group-addon"">
                                <i class=""icon-calendar bigger-110""></i>
                            </span>
                        </div>");

            return sb.ToString();
        }
            public bool ListClause(PredicateDescr pd, string functor, int arity, int seqno, out string outputString)
            {
                ClauseNode clause = null;
                string     details;
                var        sb = new StringBuilder();

                outputString = string.Empty;

                if ((clause = pd.ClauseList) == null)
                {
                    return(false);
                }

                details = "source: " + pd.DefiningFile;

                //        if (pd.IsFirstArgIndexed) details += "; arg1-indexed (jump points marked with '.')";

                sb.AppendFormat("\r\n{0}/{1}: ({2}) {3}", functor, arity, details,
                                ((seqno == 1) ? "" : (seqno.ToString().Packed())));
                sb.AppendLine();

                while (clause != null)
                {
                    bool currCachedClauseMustFail =
                        (clause is CachedClauseNode && !((CachedClauseNode)clause).Succeeds);

                    TermNode next;

                    //          // prefix a clause that is pointed to by first-argument indexing with '.'
                    //          IO.Write (" {0}{1}", (pd.IsFirstArgMarked (clause))?".":" ", nextClause.Term);
                    sb.AppendFormat("  {0}", clause.Term);

                    if (currCachedClauseMustFail)
                    {
                        sb.Append(" :- !, fail");
                    }
                    else if ((next = clause.NextNode) != null)
                    {
                        BI builtinId = next.BuiltinId;
                        sb.AppendFormat(" :-{0}", (builtinId == BI.none)
                    ? next.ToString()
                    : Environment.NewLine + builtinId.ToString());
                    }

                    sb.AppendLine(".");
                    clause = clause.NextClause;
                }

                outputString = sb.ToString();

                return(true);
            }
Example #9
0
        public Boolean Improve()
        {
            foreach (int iid in BIL.Keys)
            {
                Boolean find = false;
                foreach (Beast B in MY.Values)
                {
                    if (B.ItemId == iid)
                    {
                        B.NeedImprove = BIL[iid].count >= Beast.IMPROVE_TABLE[B.Level - 1] && Beast.IMPROVE_TABLE[B.Level - 1] > -1;
                        find          = true;
                        break;
                    }
                }
                BIL[iid].NeedIncube = !find;
            }
            Boolean RESULT = false;

            foreach (ItemBeast BI in BIL.Values)
            {
                if (BI.NeedIncube)
                {
                    RESULT = true;
                    BI.GetFromBI();
                    BI.Incube();
                }
            }
            if (RESULT)
            {
                MoveAllBeastsToStore();
                LoadInventory();
                LoadMyBeastStruct();
                LoadMyDynamic();
            }
            foreach (Beast B in MY.Values)
            {
                if (B.NeedImprove && BIL.ContainsKey(B.ItemId))
                {
                    BIL[B.ItemId].GetFromBI();
                    B.Improve();
                    RESULT = true;
                }
            }
            if (RESULT)
            {
                MoveAllBeastsToStore();
                LoadInventory();
                LoadMyBeastStruct();
                LoadMyDynamic();
            }
            return(RESULT);
        }
Example #10
0
 static BI[] GetBaseValues(string jamcoin)
 {
     var coins = new BI[9];
     for (int i = 0; i < coins.Length; i++)
     {
         coins[i] = BI.Zero;
         for (int j = 0; j < jamcoin.Length; j++)
         {
             if ('1' == jamcoin[jamcoin.Length - 1 - j])
                 coins[i] += BI.Pow(i+2, j);
         }
     }
     return coins;
 }
Example #11
0
 static List<int> GetDivisors(BI[] bases)
 {
     var divisors = new List<int>();
     foreach (var bi in bases)
     {
         int d = 1;
         while (++d < 100)
             if (bi%d == 0)
             {
                 divisors.Add(d);
                 break;
             }
     }
     return divisors;
 }
Example #12
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();


        Bvaciar.ModifyBg(StateType.Normal, new Gdk.Color(150, 150, 150));
        BD.ModifyBg(StateType.Normal, new Gdk.Color(112, 141, 242));
        BM.ModifyBg(StateType.Normal, new Gdk.Color(112, 141, 242));
        BR.ModifyBg(StateType.Normal, new Gdk.Color(112, 141, 242));
        BS.ModifyBg(StateType.Normal, new Gdk.Color(112, 141, 242));
        BI.ModifyBg(StateType.Normal, new Gdk.Color(112, 141, 242));
        // color de la pantalla
        ModifyBg(StateType.Normal, new Gdk.Color(8, 8, 8));
        //     label1.ModifyBg(StateType.Normal, new Gdk.Color(231, 231, 231));

        operaciones resultado = new operaciones();
    }
Example #13
0
        static BI[] GetBaseValues(string jamcoin)
        {
            var coins = new BI[9];

            for (int i = 0; i < coins.Length; i++)
            {
                coins[i] = BI.Zero;
                for (int j = 0; j < jamcoin.Length; j++)
                {
                    if ('1' == jamcoin[jamcoin.Length - 1 - j])
                    {
                        coins[i] += BI.Pow(i + 2, j);
                    }
                }
            }
            return(coins);
        }
Example #14
0
        public static string GenerateDropdownList(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder sb = new StringBuilder();
            DataTable dt = DbHelperSQL.Query("select * from SGP_KeyValue where [Key]=@Key and status=1 order by [Sort]", new SqlParameter("@Key", field.KeyValueSource)).Tables[0];
            sb.AppendLine(@"<select class=""form-control""  style=""width:100% !important""  id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" >");

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (field.DataValue != null)
                    {

                        if (field.DataValue.ToString().Trim().ToLower() == dt.Rows[i]["Value"].ToString().Trim().ToLower())
                        {
                            sb.AppendLine(@"<option selected = ""selected"" value=""" + dt.Rows[i]["Value"].ToString() + @""">" + dt.Rows[i]["Value"] + "</option>");
                        }
                        else
                        {
                            sb.AppendLine(@"<option value=""" + dt.Rows[i]["Value"].ToString() + @""">" + dt.Rows[i]["Value"] + "</option>");
                        }
                    }
                    else
                    {
                        sb.AppendLine(@"<option value=""" + dt.Rows[i]["Value"].ToString() + @""">" + dt.Rows[i]["Value"] + "</option>");
                    }
                }
            }
            else
            {
                sb.AppendLine(@"<option value="""">&nbsp;</option>");
            }

            sb.AppendLine(@"</select>");

            return sb.ToString();
        }
Example #15
0
            public InitialI(Ice.ObjectAdapter adapter)
            {
                _adapter = adapter;
                _b1      = new BI();
                _b2      = new BI();
                _c       = new CI();
                _d       = new DI();
                _e       = new EI();
                _f       = new FI(_e);

                _b1.theA = _b2;  // Cyclic reference to another B
                _b1.theB = _b1;  // Self reference.
                _b1.theC = null; // Null reference.

                _b2.theA = _b2;  // Self reference, using base.
                _b2.theB = _b1;  // Cyclic reference to another B
                _b2.theC = _c;   // Cyclic reference to a C.

                _c.theB = _b2;   // Cyclic reference to a B.

                _d.theA = _b1;   // Reference to a B.
                _d.theB = _b2;   // Reference to a B.
                _d.theC = null;  // Reference to a C.
            }
Example #16
0
    public InitialI(Ice.ObjectAdapter adapter)
    {
        _adapter = adapter;
        _b1 = new BI();
        _b2 = new BI();
        _c = new CI();
        _d = new DI();
        _e = new EI();
        _f = new FI(_e);

        _b1.theA = _b2; // Cyclic reference to another B
        _b1.theB = _b1; // Self reference.
        _b1.theC = null; // Null reference.

        _b2.theA = _b2; // Self reference, using base.
        _b2.theB = _b1; // Cyclic reference to another B
        _b2.theC = _c; // Cyclic reference to a C.

        _c.theB = _b2; // Cyclic reference to a B.

        _d.theA = _b1; // Reference to a B.
        _d.theB = _b2; // Reference to a B.
        _d.theC = null; // Reference to a C.
    }
Example #17
0
        public static string GenerateQueryActivity(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder strControl = new StringBuilder();
            DataTable dt = SqlText.ExecuteDataset("SELECT ID,Name FROM SYS_WFActivity WHERE Status=1 AND TemplateID=@TemplateID ORDER BY Sort", "@TemplateID", field.KeyValueSource).Tables[0];
            strControl.AppendFormat("<input type='hidden' name='{0}'><select style='width:100% !important' class='chosen-select1 tag-input-style' multiple='' data-placeholder=' ' name='{0}' id='{0}'><option value=''></option>", field.FieldName);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    strControl.AppendFormat("<option value='{0}'>{0}</option>", dr["Name"]);
                }
            }

            strControl.Append("</select>");

            return strControl.ToString();
        }
Example #18
0
 public static void M([DefaultParameterValue(1 + 3)] BI step)
 {
 }
Example #19
0
 public A()
 {
     property1 = new B();
 }
Example #20
0
        public static string GenerateTimePicker(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            string val = string.Empty;
            DateTime dt = DateTime.MinValue;

            if (field.DataValue != null)
            {
                if (field.DataValue is DateTime)
                {
                    dt = (DateTime)field.DataValue;
                }
                else
                {
                    string dtStr = field.DataValue.ToString();
                    DateTime.TryParse(dtStr, out dt);
                }
            }

            //判断是否是空日期,空日期不需要显示
            if (dt.Year > 0000)
            {
                val = dt.ToString("hh:mm:ss");
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(@"<div class=""input-group bootstrap-timepicker"">
                            <div class=""bootstrap-timepicker-widget dropdown-menu close"">
                                  <table>
                                    <tbody>
                                      <tr>
                                          <td><a href=""#"" data-action=""incrementHour""><i class=""icon-chevron-up""></i></a></td>
                                          <td class=""separator"">&nbsp;</td>
                                          <td><a href=""#"" data-action=""incrementMinute""><i class=""icon-chevron-up""></i></a></td>
                                          <td class=""separator"">&nbsp;</td>
                                          <td><a href=""#"" data-action=""incrementSecond""><i class=""icon-chevron-up""></i></a></td>
                                     </tr>
                                     <tr>
                                          <td><input type=""text"" name=""hour"" class=""bootstrap-timepicker-hour"" maxlength=""2""></td>
                                          <td class=""separator"">:</td><td><input type=""text"" name=""minute"" class=""bootstrap-timepicker-minute"" maxlength=""2""></td>
                                          <td class=""separator"">:</td><td><input type=""text"" name=""second"" class=""bootstrap-timepicker-second"" maxlength=""2""></td>
                                     </tr>
                                     <tr>
                                         <td><a href=""#"" data-action=""decrementHour""><i class=""icon-chevron-down""></i></a></td>
                                         <td class=""separator""></td>
                                        <td><a href=""#"" data-action=""decrementMinute""><i class=""icon-chevron-down""></i></a></td>
                                        <td class=""separator"">&nbsp;</td>
                                        <td><a href=""#"" data-action=""decrementSecond""><i class=""icon-chevron-down""></i></a></td>
                                     </tr>
                                    </tbody>
                                 </table>
                            </div>
                            <input class=""form-control time-picker"" class=""form-control"" id=""" + field.FieldName + @"""  name=""" + field.FieldName + @"""   type=""text"">
                            <span class=""input-group-addon"">
                                <i class=""icon-time bigger-110""></i>
                            </span>
                           </div>");

            return sb.ToString();
        }
Example #21
0
 public static string GenerateTextBoxForCurrency(BI.SGP.BLL.DataModels.FieldInfo field)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append(@"<div style=""width:100% !important""  class=""input-group""><input style=""width:100% !important""  type=""text"" class=""NumberType1"" id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" Value=""" + field.DataValue + @"""  ></div>");
     return sb.ToString();
 }
Example #22
0
        public static string GenerateTextArea(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(@"<textarea class=""form-control"" style=""width:100% !important""   id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" Value=""" + field.DataValue + @""" placeholder="""">" + field.DataValue + "</textarea>");

            return sb.ToString();
        }
Example #23
0
        public static string GenerateQueryList(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder strControl = new StringBuilder();
            DataTable dt = DbHelperSQL.Query("SELECT [Key],[Value] FROM SGP_KeyValue WHERE [Key]=@Key AND Status=1 AND ISNULL([Value],'')<>'' ORDER BY [Sort]", new SqlParameter("@Key", field.KeyValueSource)).Tables[0];
            strControl.AppendFormat("<input type='hidden' name='{0}'><select style='width:100% !important' class='chosen-select1 tag-input-style' name='{0}' id='{0}' multiple='' data-placeholder=' '><option value=''></option>", field.FieldName);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    strControl.AppendFormat("<option value='{0}'>{0}</option>", dr["Value"]);
                }
            }

            strControl.Append("</select>");

            return strControl.ToString();
        }
Example #24
0
        public static string GenerateDropdownListSQL(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder sb = new StringBuilder();

            DataTable dt = DbHelperSQL.Query(field.KeyValueSource.ToString()).Tables[0];
            if (field.DataValue == null && (field.FieldName == "Initiator" || field.FieldName == "PricingAnalyst" || field.FieldName == "PrimaryContact"))
            {
                field.DataValue = SGP.BLL.Utils.AccessControl.CurrentLogonUser.Name;
            }
            sb.AppendLine(@"<select class=""form-control"" style=""width:100% !important""  id=""" + field.FieldName + @""" name=""" + field.FieldName + @""">");

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (field.DataValue != null)
                    {
                        if (field.DataValue.ToString().Trim().ToLower() == dt.Rows[i]["Value"].ToString().Trim().ToLower())
                        {
                            sb.AppendLine(@"<option selected = ""selected"" value=""" + dt.Rows[i]["Value"].ToString() + @""">" + dt.Rows[i]["Value"] + "</option>");
                        }
                        else
                        {
                            sb.AppendLine(@"<option value=""" + dt.Rows[i]["Value"].ToString() + @""">" + dt.Rows[i]["Value"] + "</option>");
                        }
                    }
                    else
                    {
                        sb.AppendLine(@"<option value=""" + dt.Rows[i]["Value"].ToString() + @""">" + dt.Rows[i]["Value"] + "</option>");
                    }
                }
            }
            else
            {
                sb.AppendLine(@"<option value="""">&nbsp;</option>");
            }

            sb.AppendLine(@"</select>");

            return sb.ToString();
        }
Example #25
0
        private bool DoBuiltin(BI biId, out bool findFirstClause)
        {
            findFirstClause = false;
              //Console.WriteLine ("DoBuiltin case {0} current goal \n{1}", biId, goalNode.Term);

              Term term = goalNode.Term;
              Term t0, t1, t2, t3;
              TermSet ts;
              int n, y, m, d, h, s;
              int arity;
              string functor;
              char ch;
              bool result;

              switch (biId)
              {
            case BI.cut:  // !
              varStack.DisableChoices(term.VarNo);
              break;

            case BI.fail:
              return false;

            case BI.or:
              PrologIO.Error("Serious error -- or-operator (;) not handled properly"); // should not occur
              return false;

            case BI.consult: // individual file or list of files
              t0 = term.Arg(0);

              if (t0.IsList)
              {
            int lines = 0;
            int files = 0;

            while (t0.Arity == 2)
            {
              string fName = Utils.FileNameFromTerm(t0.Arg(0), ".pl");
              if (fName == null) return false;
              lines += ps.Consult(fName);
              files++;
              t0 = t0.Arg(1);
            }
            if (files > 1) PrologIO.Message("Grand total is {0} lines", lines);
            ps.ResolveIndices();
            break;
              }
              if (t0.IsAtom || t0.IsString)
              {
            string fName = Utils.FileNameFromTerm(t0, ".pl");
            if (fName == null) return false;
            PrologIO.Write("--- Consulting {0} ... ", fName);
            ps.Consult(fName);
            PrologIO.WriteLine("{0} lines read", parser.LineCount);
            ps.ResolveIndices();
            break;
              }
              return PrologIO.Error("Not a valid file name: '{0}'", t0);

            case BI.asserta:
              ps.Assert(term.Arg(0), true); // true: at beginning
              break;

            case BI.assert:
            case BI.assertz:
              ps.Assert(term.Arg(0), false);
              break;

            case BI.retract:
              if (ps.Retract(term.Arg(0), varStack, null))
            currentCp.ClauseNode = retractClause;
              else
              {
            CanBacktrack(true);
            return false;
              }
              break;

            case BI.retractall: // retractall
              if (!ps.RetractAll(term.Arg(0), varStack)) return false;
              break;

            case BI.spy: // leash modes [call, exit, redo, fail]
            case BI.nospy:
              result = true;
              t0 = term.Arg(0);

              if (term.Arity == 2) t3 = term.Arg(1); else t3 = null; // leash list

              if (t0.Functor == "/" && t0.Arity == 2 && (t1 = t0.Arg(0)).IsAtom && (t2 = t0.Arg(1)).IsInteger)
            result = ps.SetSpy(term.Functor == "spy", t1.Functor, t2.ExprValue.AsInteger, t3);
              else if (t0.Arity == 0)
            result = ps.SetSpy(term.Functor == "spy", t0.Functor, -1, t3);

              if (!result) return false;

              if (!debug)
              {
            debug = true;
            PrologIO.Message("Debugging switched on");
              }
              break;

            case BI.nospyall:
              ps.SetNoSpyAll();
              break;

            case BI.verbose:
              PrologIO.Verbose = true;
              break;

            case BI.noverbose:
            case BI.silent:
              PrologIO.Verbose = false;
              break;

            case BI.trace:
            case BI.notrace:
              SetSwitch("Tracing", ref trace, term.Functor == "trace");
              if (trace) debug = true;
              reporting = debug || xmlTrace;
              break;

            case BI.debug:
            case BI.nodebug:
              SetSwitch("Debugging", ref debug, term.Functor == "debug");
              reporting = debug || xmlTrace;
              break;

            case BI.setof_init:
              term.Arg(0).Unify(new ObjectTerm(new TermSet(DupMode.dupIgnore)), varStack);
              break;

            case BI.setof_add:
              ts = (TermSet)((ObjectTerm)term.Arg(0).Value).Value;
              t1 = term.Arg(1);
              if (t1.IsVar) return false;
              t2 = t1.CleanUp();
              ts.Insert(t2);
              break;

            case BI.setof_exit:
              ts = (TermSet)((ObjectTerm)term.Arg(0).Value).Value;
              if (ts.Count == 0) return false; // setof must fail if the Generator yields no matches
              term.Arg(1).Unify(ts.ToList(), varStack);
              break;

            case BI.current_op_init:
              int pr = -1;
              string op = null;
              OType ot = OType.noop;
              OType ot1;

              t0 = term.Arg(0);
              if (t0.IsInteger)
            pr = Convert.ToInt16(t0.ExprValue.AsInteger);
              else if (!t0.IsVar)
            return false;

              t1 = term.Arg(1);
              if (t1.IsAtom)
            try
            {
              ot = (OType)Enum.Parse(typeof(OType), t1.Functor);
            }
            catch
            {
              return false;
            }
              else if (!t1.IsVar)
            return false;

              t2 = term.Arg(2);
              if (t2.IsAtom)
            op = t2.Functor;
              else if (!t2.IsVar)
            return false;

              ArrayList ta = parser.TerminalList;
              ArrayList oa = new ArrayList();
              int pr1;
              string op1;

              for (int i = 0; i < ta.Count; i++) // expand all operator descriptors into array oa
              {
            if (ta[i] is OperatorDescr)
            {
              OperatorDescr od = (OperatorDescr)ta[i];

              if (od.IsDefinedAsPrefix(out op1, out pr1, out ot1) &&
                   (pr == -1 || pr == pr1) && (op == null || op == op1) && (ot == OType.noop || ot == ot1))
                oa.Add(new OpRec(pr1, ot1, op1));
              if (od.IsDefinedAsInfix(out op1, out pr1, out ot1) &&
                   (pr == -1 || pr == pr1) && (op == null || op == op1) && (ot == OType.noop || ot == ot1))
                oa.Add(new OpRec(pr1, ot1, op1));
              if (od.IsDefinedAsPostfix(out op1, out pr1, out ot1) &&
                   (pr == -1 || pr == pr1) && (op == null || op == op1) && (ot == OType.noop || ot == ot1))
                oa.Add(new OpRec(pr1, ot1, op1));
            }
              }

              if (oa.Count == 0) return false;

              term.Arg(3).Bind(new ObjectTerm(oa)); // bind the operator array to the penultimate argument
              term.Arg(4).Bind(new Term((oa.Count - 1).ToString(), FType.number)); // bind the array count to the last argument
              break;

            case BI.next_op: // '$next_op'(S, I, P, F, N)
              t0 = term.Arg(0);
              oa = (ArrayList)((ObjectTerm)term.Arg(0).Value).Value;
              t1 = term.Arg(1); // index of current entry in oa
              n = t1.ExprValue.AsInteger;
              OpRec oprec = (OpRec)oa[n];
              term.Arg(1).Functor = (--n).ToString();
              term.Arg(2).Unify(new Term(oprec.Pr.ToString(), FType.number), varStack);
              term.Arg(3).Unify(new Term(oprec.Fx, FType.atom), varStack);
              term.Arg(4).Unify(new Term(oprec.Op, FType.atom), varStack);
              break;

            case BI.version: // version(V, R)
              if (!term.Arg(0).Unify(new Term(Utils.MakeAtom(VERSION), FType.atom), varStack)) return false;
              if (!term.Arg(1).Unify(new Term(Utils.MakeAtom(RELEASE), FType.atom), varStack)) return false;
              break;

            case BI.halt:
            case BI.quit:
            case BI.abort:
              halted = true;
              break;

            case BI.length: // length(L, N)
              t0 = term.Arg(0);
              if (t0.HasValue)
              {
            if (!t0.IsList) return false;
            n = 0;
            while (t0.Arity == 2)
            {
              n++;
              t0 = t0.Arg(1);
            }
            if (!term.Arg(1).Unify(new Term(n.ToString(), FType.number), varStack)) return false;
              }
              else // create a list with N elements
              {
            t1 = term.Arg(1);
            if (!t1.HasValue) return false;
            arity = Convert.ToInt16(t1.ExprValue.AsInteger);
            Term[] args = new Term[arity];
            t1 = Term.NULLLIST; // []
            for (int i = 0; i < arity; i++)
              t1 = new Term(Parser.DOT, new Term(), t1, FType.comp, OType.xfy, 100);
            t0.Unify(t1, varStack);
              }
              break;

            case BI.sort: // sort(L, S)
              t0 = term.Arg(0);
              t1 = term.Arg(1);

              if (t0.IsList)
              {
            if (!(t1.IsList || t1.IsVar)) return false;

            TermSet tlist = new TermSet(t0);
            tlist.Sort();

            if (!t1.Unify(tlist.ToList(), varStack)) return false;
              }
              else
            return false;
              break;

            case BI.functor: // functor(T, F, N)
              t0 = term.Arg(0);
              if (t0.HasValue)
              {
            if (!term.Arg(1).Unify(new Term(t0.Functor, 0), varStack)) return false;
            if (!term.Arg(2).Unify(new Term(t0.Arity.ToString(), FType.number), varStack)) return false;
            break;
              }
              else // Term (t0) is unbound
              {
            t1 = term.Arg(1);
            if (t1.HasValue) functor = t1.Functor; else return false;

            t2 = term.Arg(2);
            if (t2.HasValue) arity = Convert.ToInt16(t2.ExprValue.AsInteger); else return false;

            Term[] args = new Term[arity];
            for (int i = 0; i < arity; i++) args[i] = new Term();
            if (arity == 0)
              t2 = (functor == Parser.DOT) ? Term.NULLLIST : new Term(functor);
            else if (arity > 2)
              t2 = new Term(functor, args);
            else
            {
              OperatorDescr od = Parser.GetOperatorDescr(functor);

              if (od == null)
                t2 = new Term(functor, args);
              else if (arity == 1 &&
                        (od.IsDefinedAsPrefix(out functor, out pr, out ot) ||
                         od.IsDefinedAsPostfix(out functor, out pr, out ot)))
                t2 = new Term(functor, od, args, ot, pr);
              else if (arity == 2 && od.IsDefinedAsInfix(out functor, out pr, out ot))
                t2 = new Term(functor, od, args, ot, pr);
              else
                t2 = new Term(functor, args);
            }
            if (!t0.Unify(t2, varStack)) return false;
            break;
              }

            case BI.arg: // arg( N, Term, A)
              t1 = term.Arg(1);
              n = term.Arg(1).NArgs;
              if (n <= 0) return false;
              n = Convert.ToInt32(term.Arg(0).ExprValue.AsInteger);
              Term arg = t1.Arg(n - 1); // N is 1-based
              if (arg == null || !arg.Unify(term.Arg(2), varStack)) return false;
              break;

            case BI.abolish: // abolish( X/N)
              t0 = term.Arg(0);
              result = true;
              if (t0.Functor == "/" && t0.Arity == 2 && t0.Arg(0).IsAtom && t0.Arg(1).IsInteger)
            result = ps.Abolish(t0.Arg(0).Functor, t0.Arg(1).Functor);
              else
            result = false;
              if (!result) return false;
              break;

            case BI.gensym: // gensym( X)
              t0 = new Term("v" + gensymInt++, 0);

              if (t0.Unify(term.Arg(0), varStack))
            break;
              else
            return false;

            case BI.var:
              if (term.Arg(0).IsVar) break;
              return false;

            case BI.nonvar:
              if (term.Arg(0).IsNonVar) break;
              return false;

            case BI.atom_:
              if (term.Arg(0).IsAtom) break;
              return false;

            case BI.atomic:
              if (term.Arg(0).IsAtomic) break;
              return false;

            case BI.integer:
              if (term.Arg(0).IsInteger) break;
              return false;

            case BI.float_:
              if (term.Arg(0).IsFloat) break;
              return false;

            case BI.number:
              if (term.Arg(0).IsNumber) break;
              return false;

            case BI.compound:
              if (term.Arg(0).IsCompound) break;
              return false;

            case BI.list:
              if (term.Arg(0).IsList) break;
              return false;

            case BI.string_:
              if (term.Arg(0).IsString) break;
              return false;

            case BI.isdatetime:
              if (term.Arg(0).IsDateTime) break;
              return false;

            case BI.istimespan:
              if (term.Arg(0).IsTimeSpan) break;
              return false;

            case BI.is_: // X is Y
              t0 = new Term(term.Arg(1).ExprValue);
              if (term.Arg(0).Unify(t0, varStack)) break;
              return false;

            case BI.ne_uni: // X \= Y
              if (term.Arg(0).Unify(term.Arg(1), varStack)) return false;
              break;

            case BI.eq_num: // X =:=
              if (term.Arg(0).ExprValue.AsNumber == term.Arg(1).ExprValue.AsNumber) break;
              return false;

            case BI.ne_num: // X =\= Y
              if (term.Arg(0).ExprValue.AsNumber != term.Arg(1).ExprValue.AsNumber) break;
              return false;

            case BI.lt_num:  // X < Y
              if (term.Arg(0).ExprValue.AsNumber < term.Arg(1).ExprValue.AsNumber) break;
              return false;

            case BI.le_num: // X =< Y
              if (term.Arg(0).ExprValue.AsNumber <= term.Arg(1).ExprValue.AsNumber) break;
              return false;

            case BI.gt_num: // X > Y
              if (term.Arg(0).ExprValue.AsNumber > term.Arg(1).ExprValue.AsNumber) break;
              return false;

            case BI.ge_num: // X >= Y
              if (term.Arg(0).ExprValue.AsNumber >= term.Arg(1).ExprValue.AsNumber) break;
              return false;

            case BI.eq_str: // X == Y
              if (term.Arg(0).CompareTo(term.Arg(1)) == 0) break;
              return false;

            case BI.ne_str: // X \== Y
              if (term.Arg(0).CompareTo(term.Arg(1)) != 0) break;
              return false;

            case BI.lt_ord: // X @< Y
              if (term.Arg(0).CompareTo(term.Arg(1)) < 0) break;
              return false;

            case BI.le_ord: // X @=< Y
              if (term.Arg(0).CompareTo(term.Arg(1)) <= 0) break;
              return false;

            case BI.gt_ord: // X @> Y
              if (term.Arg(0).CompareTo(term.Arg(1)) > 0) break;
              return false;

            case BI.ge_ord: // X @>= Y
              if (term.Arg(0).CompareTo(term.Arg(1)) >= 0) break;
              return false;

            case BI.univ: // X =.. Y
              t0 = term.Arg(0);
              if (t0.HasValue) // create a list representation of the lhs and unify that with the rhs
              {
            functor = t0.Functor;
            arity = t0.Arity;
            Term[] args = new Term[arity];
            t1 = Term.NULLLIST; // []
            for (int i = arity; i > 0; i--) t1 = new Term(Parser.DOT, t0.Arg(i - 1), t1, FType.comp, OType.xfy, 100); // [arg1, arg2, ...]
            t1 = new Term(Parser.DOT, new Term(functor), t1, FType.comp, OType.yfx, 0); // [functor, arg1, arg2, ...]
            if (!t1.Unify(term.Arg(1), varStack)) return false;
            break;
              }
              else // Term is unbound. Create a function representation of the list rhs, and bind that to the lhs
              {
            t1 = term.Arg(1);
            if (!t1.HasValue || !t1.IsList) return false;
            if (t1.Arg(0) == null) return false; // empty list
            functor = t1.Arg(0).Functor;
            // convert rest of list to arguments: calculate arity first
            t1 = t1.Arg(1);
            arity = 0;
            t2 = t1;
            while (t2.Arity == 2)
            {
              arity++;
              t2 = t2.Arg(1);
            }
            // create arguments
            Term[] args = new Term[arity];
            for (int i = 0; i < arity; i++)
            {
              args[i] = t1.Arg(0);
              t1 = t1.Arg(1);
            }
            t1 = new Term(functor, args);
            t0.Unify(t1, varStack);
            break;
              }

            case BI.unifiable: // X can be unified with Y, but without variable bindings
              if (!term.Arg(0).Unifiable(term.Arg(1), varStack)) return false;
              break;

            case BI.see: // see(X)
              currentInputName = Utils.FileNameFromTerm(term.Arg(0), ".pl");
              if (currentInputName == null) return false;
              currentInputReader = new StreamReader(currentInputName);
              Console.SetIn(currentInputReader);
              break;

            /*
                case BI.see: // see(X)  // ORIGINAL VERSION, INTENDED FOR USE WITH read/1
                    try
                    {
                      currentInputName = null;
                      while (seeParserThread.IsAlive)
                      {
                        Utils.WriteLine ("Waiting to abort");
                        seeParserThread.Interrupt ();
                        seeParserThread.Abort ();
                      }
                    }
                    catch {}
                  currentInputName = Utils.FileNameFromTerm (term.Arg (0), ".pl");
                  if (currentInputName == null) return false;
               Utils.WriteLine ("File {0}", currentInputName);
                  Monitor.Enter (TermMonitor);
               Utils.WriteLine ("see: Monitor entered");
                  seeParserRun = new ThreadStart (RunSeeParser);
                  seeParserThread = new Thread (seeParserRun);
                  seeParserThread.IsBackground = true; // nodig?
                  seeParserThread.Start ();
               Utils.WriteLine ("see: Thread started");
                  break;
            */
            case BI.read: // read(X)
              try
              {
            if (currentInputName == null) return false;
            // Monitor.Enter () was issued in see (F)
            Monitor.Pulse(TermMonitor);
            if (Monitor.Wait(TermMonitor, 2000))
            {
              t0 = term.Arg(0);
              if (!t0.Unify(parser/*seeParser*/.ReadTerm, varStack)) return false;
            }
            else // time-out
            {
              Utils.WriteLine("read: Monitor.Wait () timed out");
              return false;
            }
              }
              finally
              {
            if (parser/*seeParser*/.AtEndOfInput)
            {
              currentInputName = null;
              try { Monitor.Exit(TermMonitor); }
              catch { }
            }
              }
              break;

            case BI.get0: // get0(C): any character
              n = (char)Console.ReadKey().KeyChar;
              if (!term.Arg(0).Unify(new Term(n.ToString(), FType.number), varStack)) return false;
              break;

            case BI.get: // get( C): skip non-printables
              do
              {
            n = Console.ReadKey().KeyChar;
            if (!Char.IsControl((char)n)) break; // break if printable
              } while (true);
              if (!term.Arg(0).Unify(new Term(n.ToString(), FType.number), varStack)) return false;
              break;

            case BI.seek: // seek( N, C)
              n = Convert.ToInt32(term.Arg(0).ExprValue.AsInteger);
              if (!parser/*seeParser*/.StreamInChar(n, out ch)) return false;
              if (!term.Arg(0).Unify(new Term(ch.ToString()), varStack)) return false;
              break;

            case BI.seen: // seen
              currentInputName = null;
              if (seeParserThread != null) seeParserThread.Abort();
              seeParserThread = null;  // implicitly set by Abort?
              break;

            case BI.tell: // tell( F)
              if (!Globals.SetCurrentOutput(Utils.FileNameFromTerm(term.Arg(0), ".pl"))) return false;
              break;

            case BI.write: // write( X)
              PrologIO.PrologPrint(term.Arg(0));
              break;

            case BI.writeq: // writeq( X)
              PrologIO.PrologPrint(term.Arg(0).ToStringQ());
              break;

            case BI.writeln: // writeln( X)
              PrologIO.PrologPrint(term.Arg(0));
              PrologIO.PrologPrint(Environment.NewLine);
              break;

            case BI.put: // put( C)
              n = Convert.ToInt32(term.Arg(0).ExprValue.AsInteger);
              PrologIO.PrologPrint(((char)n).ToString());
              break;

            case BI.nl:
              PrologIO.PrologPrint(Environment.NewLine);
              break;

            case BI.tab: // tab( +N)
              ////////////////////////// testen op Int
              n = Convert.ToInt32(term.Arg(0).ExprValue.AsInteger);
              PrologIO.PrologPrint(new String(' ', n));
              break;

            case BI.display: // like writeln ( X), but always to standard ouput
              Globals.SetStandardOutput();
              PrologIO.PrologPrint(term.Arg(0));
              PrologIO.PrologPrint(Environment.NewLine);
              Globals.RevertToCurrentOutput();
              break;

            case BI.told:
              Globals.TryCloseCurrentOutput();
              break;

            case BI.atom_chars: // name( ?A, ?L)
            case BI.name: // name( ?A, ?L)
              t1 = term.Arg(1);
              if (t1.HasValue)
              {
            FType fType;
            string a;

            if (t1.IsList)
            {
              StringBuilder sb = new StringBuilder();
              while (t1.Arity == 2)
              {
                t2 = t1.Arg(0);
                if (!t2.IsInteger) return false;
                sb.Append((char)t2.ExprValue.AsInteger);
                t1 = t1.Arg(1);
              }
              a = Utils.MakeAtom_ic(sb.ToString(), true, out fType);
              if (!term.Arg(0).Unify(new Term(a, fType), varStack)) return false;
            }
            else if (t1.IsString)
            {
              a = Utils.MakeAtom_ic(t1.Functor, true, out fType);
              if (!term.Arg(0).Unify(new Term(a, fType), varStack)) return false;
            }
            else
              return false;
              }
              else // create a list containing A's character codes
              {
            t0 = term.Arg(0);
            if (!t0.IsAtomic) return false;
            char[] chars = t0.Functor.ToCharArray();
            t0 = Term.NULLLIST; // []
            for (int i = chars.Length - 1; i >= 0; i--)
            {
              t2 = new Term(((int)chars[i]).ToString(), FType.number);
              t0 = new Term(Parser.DOT, t2, t0, FType.comp, OType.xfy, 100);
            }
            t1.Unify(t0, varStack);
              }
              break;

            case BI.expand_term: // expand_term( +(P-->Q), -R)
              t0 = term.Arg(0); // P-->Q
              t1 = term.Arg(1); // R
              Term head = t0.Arg(0);
              TermNode body = t0.Arg(1).ToDCG(ref head);
              t2 = new Term(new ClauseNode(head, body)).CleanUp();
              if (!t1.Unify(t2, varStack)) return false;
              break;

            case BI.numbervars: // numbervars(+X, +B, -E)
              t0 = term.Arg(0);
              t1 = term.Arg(1);
              t2 = term.Arg(2);
              if (!t1.IsInteger || t2.HasValue) return false;
              int k = (int)t1.ExprValue.AsInteger;
              t0.NumberVars(ref k, varStack);
              t2.Unify(new Term(k.ToString(), FType.number), varStack);
              break;

            case BI.writef0: // writef( S, L)
              t0 = term.Arg(0);
              t1 = term.Arg(1);
              if (!t0.IsString) return false;
              ArrayList al = new ArrayList();
              while (t1.Arity == 2)
              {
            t2 = t1.Arg(0);
            string a = null;
            if (t2.Functor == "tree" && t2.Arity == 1)
              a = t2.Arg(0).ToTree();
            else if (t2.Functor == "raw" && t2.Arity == 1)
              a = t2.Arg(0).ToRaw();
            al.Add((a == null) ? t2.ToString() : a);
            t1 = t1.Arg(1);
              }
              PrologIO.WriteLine(t0.Functor, al.ToArray());
              break;

            case BI.writef: // writef( S)
              t0 = term.Arg(0);
              if (!t0.IsString) return false;
              PrologIO.WriteLine(t0.Functor);
              break;

            case BI.username: // username( X)
              if (!term.Arg(0).Unify(new Term(Environment.UserName), varStack)) return false;
              break;

            case BI.shell: // shell( X [,Args])
              t0 = term.Arg(0);
              if (!(t0.IsString || t0.IsAtom))
            return false;
              else if (term.Arity == 1)
            Process.Start(t0.Functor);
              else if (!((t1 = term.Arg(1)).IsString || t1.IsAtom))
            return false;
              else
            Process.Start(t0.Functor, Utils.Dequoted(t1.Functor));
              break;

            /*
            namespace MyProcessSample
            {
            /// <summary>
            /// Shell for the sample.
            /// </summary>
            class MyProcess
            {
                // These are the Win32 error code for file not found or access denied.
                const int ERROR_FILE_NOT_FOUND =2;
                const int ERROR_ACCESS_DENIED = 5;

                /// <summary>
                /// Prints a file with a .doc extension.
                /// </summary>
                void PrintDoc()
                {
                    Process myProcess = new Process();

                    try
                    {
                        // Get the path that stores user documents.
                        string myDocumentsPath =
                            Environment.GetFolderPath(Environment.SpecialFolder.Personal);

                        myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc";
                        myProcess.StartInfo.Verb = "Print";
                        myProcess.StartInfo.CreateNoWindow = true;
                        myProcess.Start();
                    }
                    catch (Win32Exception e)
                    {
                        if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
                        {
                            Console.WriteLine(e.Message + ". Check the path.");
                        }

                        else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
                        {
                            // Note that if your word processor might generate exceptions
                            // such as this, which are handled first.
                            Console.WriteLine(e.Message +
                                ". You do not have permission to print this file.");
                        }
                    }
                }
            */

            case BI.predicatePN: // predicate( +P/N)
              t0 = term.Arg(0);
              result = true;
              if (t0.Functor == "/" && t0.Arity == 2 && t0.Arg(0).IsAtom && t0.Arg(1).IsInteger)
            result = ps.IsPredicate(t0.Arg(0).Functor, (int)t0.Arg(1).ExprValue.AsInteger);
              else
            result = false;
              if (!result) return false;
              break;

            case BI.predicateX: // predicate( +T)
              t0 = term.Arg(0);
              if (t0.IsVar || !ps.IsPredicate(t0.Functor, t0.NArgs)) return false;
              break;

            #if persistent
            case BI.retract_where: // retract(X) where Y -- for persistent predicates only. No backtracking, delete the whole shebang in one go
              t0 = term.Arg (0).Arg (0); // X
              if (!ps.IsPersistent (t0)) IO.Error ("retract/1: 'where' not allowed on non-persistent predicate {0}", t0.KbKey);
              t1 = term.Arg (1); // Y
              if (!ps.Retract (t0, varStack, t1)) return false;
              break;

            case BI.persistent: // persistent( +P/N)
              t0 = term.Arg (0);
              result = true;
              if (t0.Functor == "/" && t0.Arity == 2 && t0.Arg (0).IsAtom && t0.Arg (1).IsInteger)
            result = ps.IsPersistent (t0.Arg (0).Functor, (int)t0.Arg (1).ExprValue.AsInteger);
              else
            result = false;
              if (!result) return false;
              break;

            case BI.whereXY: // X where Y
              t0 = term.Arg (0); // X
              if (!ps.IsPersistent (t0)) IO.Error ("'where' not allowed on non-persistent predicate {0}", t0.KbKey);
              t1 = term.Arg (1); // Y
              // insert the goal in the argument into the current goalNode
              goalNode = t0.ToGoalList ().Append (goalNode.NextNode);
              goalNode.FindPredicateDefinition (ps, t1);
              return true;

            case BI.persistent_info: // persistent_info( X/N, L) -- give a list with a description of each column
              t0 = term.Arg (0);
              t1 = term.Arg (1);
              t2 = null;

              if (t0.Functor == "/" && t0.Arity == 2 && t0.Arg (0).IsAtom && t0.Arg (1).IsInteger)
            t2 = ps.PersistentInfo (t0.Arg (0).Functor, t0.Arg (1).Functor);
              else
            return false;

              if (!t1.Unify (t2, varStack)) return false; // t1 is output-arg
              break;

            case BI.persistent_uncache: // persistent_uncache( X/N) -- empty persistent predicate X/N's cache
              t0 = term.Arg (0);
              t1 = term.Arg (1);
              PredicateDescr pd;
              if (t0.Functor == "/" && t0.Arity == 2 && t0.Arg (0).IsAtom && t0.Arg (1).IsInteger)
            pd = ps [Term.Key (t0.Arg (0).Functor, t0.Arg (1).Functor)];
              else
            return false;
              if (pd == null || !(pd is PersistentPredDescr))
              {
            IO.Warning ("Predicate '{0}/{1}' was not declared as persistent", t0.Arg (0).Functor, t0.Arg (1).Functor);
            return false;
              }
              ((PersistentPredDescr)pd).InvalidateCache ();
              break;
            #endif

            case BI.ground: // ground( +T)
              if (!term.Arg(0).IsGround()) return false;
              break;

            case BI.today: // date( ?Y, ?M, ?D)
              y = DateTime.Today.Year;
              m = DateTime.Today.Month;
              d = DateTime.Today.Day;
              if (!term.Arg(0).Unify(new Term(y.ToString(), FType.number), varStack)) return false;
              if (!term.Arg(1).Unify(new Term(m.ToString(), FType.number), varStack)) return false;
              if (!term.Arg(2).Unify(new Term(d.ToString(), FType.number), varStack)) return false;
              break;

            case BI.now: // time( ?H, ?M, ?S)
              h = DateTime.Now.Hour;
              m = DateTime.Now.Minute;
              s = DateTime.Now.Second;
              if (!term.Arg(0).Unify(new Term(h.ToString(), FType.number), varStack)) return false;
              if (!term.Arg(1).Unify(new Term(m.ToString(), FType.number), varStack)) return false;
              if (!term.Arg(2).Unify(new Term(s.ToString(), FType.number), varStack)) return false;
              break;

            case BI.validdate: // validdate( +Y, +M, +D)
              t0 = term.Arg(0);
              if (t0.IsInteger) y = (int)t0.ExprValue.AsInteger; else return false;
              t1 = term.Arg(1);
              if (t1.IsInteger) m = (int)t1.ExprValue.AsInteger; else return false;
              t2 = term.Arg(2);
              if (t2.IsInteger) d = (int)t2.ExprValue.AsInteger; else return false;
              try { new DateTime(y, m, d); }
              catch { return false; }
              break;

            case BI.validtime: // validtime( +H, +M, +S)
              t0 = term.Arg(0);
              if (t0.IsInteger) h = (int)t0.ExprValue.AsInteger; else return false;
              t1 = term.Arg(1);
              if (t1.IsInteger) m = (int)t1.ExprValue.AsInteger; else return false;
              t2 = term.Arg(2);
              if (t2.IsInteger) s = (int)t2.ExprValue.AsInteger; else return false;
              try { new DateTime(2000, 1, 1, h, m, s); }
              catch { return false; }
              break;

            case BI.dayname: // dayname( +Y, +M, +D, ?N)
              DayOfWeek dow;
              t0 = term.Arg(0);
              if (t0.IsInteger) y = (int)t0.ExprValue.AsInteger; else return false;
              t1 = term.Arg(1);
              if (t1.IsInteger) m = (int)t1.ExprValue.AsInteger; else return false;
              t2 = term.Arg(2);
              if (t2.IsInteger) d = (int)t2.ExprValue.AsInteger; else return false;
              try { dow = new DateTime(y, m, d).DayOfWeek; }
              catch { return false; }
              if (!term.Arg(3).Unify(new Term(dow.ToString("G"), FType.text), varStack)) return false;
              break;

            case BI.dayofweek: // dayofweek( +Y, +M, +D, ?N)
              t0 = term.Arg(0);
              if (t0.IsInteger) y = (int)t0.ExprValue.AsInteger; else return false;
              t1 = term.Arg(1);
              if (t1.IsInteger) m = (int)t1.ExprValue.AsInteger; else return false;
              t2 = term.Arg(2);
              if (t2.IsInteger) d = (int)t2.ExprValue.AsInteger; else return false;
              try { n = (int)new DateTime(y, m, d).DayOfWeek; }
              catch { return false; }
              if (!term.Arg(3).Unify(new Term(n.ToString(), FType.number), varStack)) return false;
              break;

            case BI.dayofyear: // dayofyear( +Y, +M, +D, ?N)
              t0 = term.Arg(0);
              if (t0.IsInteger) y = (int)t0.ExprValue.AsInteger; else return false;
              t1 = term.Arg(1);
              if (t1.IsInteger) m = (int)t1.ExprValue.AsInteger; else return false;
              t2 = term.Arg(2);
              if (t2.IsInteger) d = (int)t2.ExprValue.AsInteger; else return false;
              try { n = (int)new DateTime(y, m, d).DayOfYear; }
              catch { return false; }
              if (!term.Arg(3).Unify(new Term(n.ToString(), FType.number), varStack)) return false;
              break;

            case BI.leapyear: // leapyear( +Y)
              t0 = term.Arg(0);
              if (t0.IsInteger) y = (int)t0.ExprValue.AsInteger; else return false;
              if (!DateTime.IsLeapYear(y)) return false;
              break;

            case BI.weekno: // weekno(+Y, +M, +D, ?N) // week number of date Y-M-D, or current week number
              if (term.Arity == 4)
              {
            t0 = term.Arg(0);
            if (t0.IsInteger) y = (int)t0.ExprValue.AsInteger; else return false;
            t1 = term.Arg(1);
            if (t1.IsInteger) m = (int)t1.ExprValue.AsInteger; else return false;
            t2 = term.Arg(2);
            if (t2.IsInteger) d = (int)t2.ExprValue.AsInteger; else return false;
            try { n = Utils.WeekNo(new DateTime(y, m, d)); }
            catch { return false; } // invalid date
              }
              else
            n = Utils.WeekNo(DateTime.Today);
              if (!term.Arg(term.Arity - 1).Unify(new Term(n.ToString(), FType.number), varStack)) return false;
              break;
            case BI.prob:
              if (!term.Arg(0).Unify(new Term(new Prolog.Term.NumberValue(new decimal(resProb))), varStack)) return false;
              break;
            case BI.probdebuglevel:
              t0 = term.Arg(0);
              if (t0.IsInteger) probDebugLevel = (int)t0.ExprValue.AsInteger;
              PrologIO.WriteLine("Probability debug level:" + probDebugLevel);
              break;
            case BI.probtimedecay:
              t0 = term.Arg(0);
              if (!t0.IsString || t0.Functor == null) return false;
              timeDecayEnabled = ("yes".Equals(t0.Functor.ToLower()) || "y".Equals(t0.Functor.ToLower()));
              PrologIO.WriteLine("Probability time decay:" + timeDecayEnabled);
              break;
            case BI.xml_term: // xml_term( [C,] ?X, ?P) converts between XML and Prolog representation
              string x;
              Term ss = null;
              bool settings = (term.Arity == 3);

              if (settings)
              {
            ss = term.Arg(0);
            t0 = term.Arg(1);
            t1 = term.Arg(2);
              }
              else
              {
            t0 = term.Arg(0);
            t1 = term.Arg(1);
              }

              if (t0.HasValue)
              {
            x = t0.Functor;
            bool inFile = (t0.Arity == 1 && x == "see");  // is it the name of a source file containing the XML structure?
            bool outFile = (t0.Arity == 1 && x == "tell"); // ... or the name of a destination file containing the XML structure?
            if (inFile || outFile)
            {
              x = Utils.FileNameFromTerm(t0.Arg(0), ".xml");
              if (x == null) return false;
            }
            if (outFile)
            {
              if (!t1.HasValue) return false;

              if (!Node.TermToXml(ss, t1, ref x)) return false;
            }
            else
            {
              t2 = Node.XmlToTerm(x, inFile);
              //Console.WriteLine (t2.ToTree ());
              if (!t1.Unify(t2, varStack)) return false;
            }
            break;
              }
              else if (t1.HasValue)
              {
            x = null;
            if (!Node.TermToXml(ss, t1, ref x)) return false;
            t2 = new Term(x, FType.text);
            if (!t0.Unify(t2, varStack)) return false;
            break;
              }
              else
            return false;

            case BI.listing: // listing
              if (!ps.ListAll(null, -1, false, true)) return false; // i.e. no predefined, all user
              break;

            case BI.listingXN: // listing( X/N)
              t0 = term.Arg(0);
              result = true;
              if (t0.Functor == "/" && t0.Arity == 2 && t0.Arg(0).IsAtom && t0.Arg(1).IsInteger)
            result = ps.ListAll(t0.Arg(0).Functor, t0.Arg(1).ExprValue.AsInteger, false, true);
              else
            result = false;
              if (!result) return false;
              break;

            case BI.listingX: // listing( X) -- list all predicates X/N (i.e. for each N)
              t0 = term.Arg(0);
              if (!t0.IsAtom) return false;
              if (!ps.ListAll(t0.Functor, -1, false, true)) return false;
              break;

            case BI.listing0: // listing0
              if (!ps.ListAll(null, -1, true, false)) return false; // i.e. no user, all predefined
              break;

            case BI.listing0XN: // listing0( X/N)
              t0 = term.Arg(0);
              result = true;
              if (t0.Functor == "/" && t0.Arity == 2 && t0.Arg(0).IsAtom && t0.Arg(1).IsInteger)
            result = ps.ListAll(t0.Arg(0).Functor, t0.Arg(1).ExprValue.AsInteger, true, false);
              else
            result = false;
              if (!result) return false;
              break;

            case BI.listing0X: // listing0( X)
              t0 = term.Arg(0);
              if (!t0.IsAtom) return false;
              if (!ps.ListAll(t0.Functor, -1, true, false)) return false;
              break;

            case BI.pp_defines: // pp_defines( X) -- preprocessor symbol definitions -- mainly useful for debugging in nested calls
              t0 = term.Arg(0);
              if (!t0.IsVar) return false;
              t1 = Term.NULLLIST; // []
              //Console.WriteLine ("Parser.PpSymbols.count = {0}", Parser.PpSymbols.Count);
              foreach (DictionaryEntry de in Parser.PpSymbols)
            t1 = new Term(Utils.MakeAtom(de.Key as string), new Term(), t1, FType.comp, OType.xfy, 100);
              t0.Unify(t1, varStack);
              break;

            case BI.undefineds:
              ps.FindUndefineds();
              break;

            case BI.copy_term: // copy_term( X, Y)
              if (!term.Arg(1).Unify(term.Arg(0).CleanCopy(), varStack)) return false;
              break;

            case BI.undef_pred_action: // undef_pred_action( X/1, A)
              t0 = term.Arg(0);
              t1 = term.Arg(1);
              t2 = new Term(Parser.COMMA, t0, t1, FType.comp, OType.xfy, 1000);
              if (!ps.SetUndefPredAction(t2, false)) return false;
              break;

            case BI.clearall: // clearall
              ReadBuiltinPredicates();
              break;

            case BI.spypoints: // spypoints
              ps.ShowSpypoints();
              break;

            case BI.clause: // clause(Head,Body)
              t0 = term.Arg(0); // head
              t1 = term.Arg(1); // body

              if (!t0.HasValue)
              {
            // head is not instantiated --> no predicate specified
            // changed from Console.Writeln to general warning LI 2009/10/07
            PrologIO.Warning("ERROR: Arguments are not sufficiently instantiated for clause/2.");
            return false;
              }

              // find predicate
              PredicateDescr pdsc = ps[t0.KbKey];
              if (pdsc == null) return false;

              // get current clause for it
              TermNode tn = ((lastCp != null) && (lastCp is ClauseChoicePoint)) ?
            ((ClauseChoicePoint)lastCp).NextClause : pdsc.GetClauseList(t0, null);

              if (tn == null) return false;

              // prepare for redo //maybe only needed if further tn clause existent?
              varStack.Push(new ClauseChoicePoint(goalNode, goalNode.NextClause, tn.NextClause));
              findFirstClause = true;

              // unify t0 with the head and t1 with the clause
              if (!tn.Term.Unify(t0, varStack))
            return false;

              TermNode tm = tn.NextNode;

              if ((tm == null) || (tm.BuiltinId != BI.none))
              {
            // No body for the clause. Either a fact (unify t1 with TRUE) or a buildin predicate.
            if (!t1.Unify(new Term(Utils.MakeAtom(tm == null ? "true" : "builtin predicate"),
                FType.atom), varStack)) return false;
              }
              else if (tm.NextNode == null)
              {
            // body consists of one single goal.
            if (!tm.Term.Unify(t1, varStack)) return false;
              }
              else
              {
            t0 = t0.TermSeq(tm);

            if (!t0.Unify(t1, varStack)) return false;
              }
              break;

            case BI.member: // member( X, L, Rest)
              if (!(t0 = term.Arg(0)).HasValue || !(t1 = term.Arg(1)).IsList) return false;

              result = false;

              while (t1.Arity == 2)
              {
            if (result = t0.Unify(t1.Arg(0), varStack)) break;

            t1 = t1.Arg(1);
              }
              currentCp.Kill(); // no backtracking to follow -> remove the choicepoint for the alternative clauses
              if (!result) return false;
              break;

            // BACKTRACKING VERSION
            //          while (t1.Arity == 2)
            //          {
            //            if (result = t0.Unify (t1.Arg (0), varStack))
            //            {
            //              if ((t0 = t1.Arg (1)).Arity == 0) // empty list
            //                currentCp.Kill (); // no backtracking to follow -> remove the choicepoint for the alternative clauses
            //              else
            //                term.Arg (2).Bind (t0);  // set Rest to remainder of list (for backtracking)
            //
            //              break;
            //            }
            //            t1 = t1.Arg (1);
            //          }

            case BI.append: // append( [_|_], [_|_], L)
              if (!(t0 = term.Arg(0)).IsList || !(t1 = term.Arg(1)).IsList) return false;

              currentCp.Kill(); // no backtracking to follow -> remove the choicepoint for the alternative clauses

              if (!term.Arg(2).Unify(t0.AppendList(t1), varStack)) return false;
              break;

            case BI.match_regex: // regex( +Source, +Pattern, ?Result, ?Options)
              if (!((t0 = term.Arg(0)).IsString || t0.IsAtom) || !((t1 = term.Arg(1)).IsString || !t1.IsAtom)) return false;

              Match[] matches = Utils.FindRegexMatches(t0.Functor, t1.Functor, false);

              if (matches.Length == 0) return false;

              //foreach (Match mt in matches) Console.WriteLine ("index {0} match {1}", mt.Index, mt.Value);

              t2 = Term.NULLLIST; // []
              bool asAtom = true;

              for (int i = matches.Length - 1; i >= 0; i--)
            t2 = new Term(Parser.DOT, Term.MakeMatchTerm(matches[i], asAtom), t2, FType.comp, OType.xfy, 100);

              if (!term.Arg(2).Unify(t2, varStack)) return false;
              break;

            case BI.xmltrace: // xmltrace( X) -- send the execution tree of the next query to file X
              // Must be the first goal of a query, in order to avoid problems that
              // arise when it gets involved in backtracking.
              if (xmlTrace)
            PrologIO.Error("Execution trace is already being logged in {0}", xmlFile);
              else if (!(t0 = term.Arg(0)).IsAtom && !t0.IsString)
            PrologIO.Error("Not a valid file name: '{0}'", t0);
              else if (!firstGoal)
              {
            PrologIO.WriteLine("{0}*** {1}/1/2 must be the first goal of the query -- ignored{0}",
                          Environment.NewLine, term.Functor);
            break;
              }
              else if ((xmlFile = Utils.FileNameFromTerm(t0, ".xml")) == null)
            return false;

              n = (term.Arity == 2) ? term.Arg(1).ExprValue.AsInteger : INF;

              if (n < 1) PrologIO.Error("Maximum number of elements must exceed 0");

              XmlTraceOpen(term.Functor, n);
              break;

            case BI.numcols: // numcols( N) -- number of columns in the DOS-box
            #if mswindows
              if (!term.Arg(0).Unify(new Term(Utils.NumCols.ToString(), FType.number), varStack)) return false;
              break;
            #else
              return false;
            #endif

            case BI.userroles:
            #if mswindows
              WindowsIdentity ident = WindowsIdentity.GetCurrent();
              WindowsPrincipal principal = new WindowsPrincipal(ident);
              //bool admin = principal.IsInRole (WindowsBuiltInRole.Administrator);
              PrologIO.Message("{0} belongs to: ", principal.Identity.Name.ToString());

              Array wbirFields = Enum.GetValues(typeof(WindowsBuiltInRole));

              foreach (object roleName in wbirFields)
              {
            try
            {
              PrologIO.Message("{0}? {1}.", roleName, principal.IsInRole((WindowsBuiltInRole)roleName));
            }
            catch (Exception)
            {
              PrologIO.Message("Could not obtain role for RID {0}", roleName);
            }
              }
            #else
              PrologIO.Error ("userroles only available if compiler symbol mswindows is defined");
            #endif
              break;

            case BI.statistics: // statistics( X, [MSec,_]) // this version actually only returns the current time
              t1 = term.Arg(1).Arg(0);
              long time = ClockTicksMSecs();
              if (!t1.Unify(new Term(time.ToString(), FType.number), varStack)) return false;
              break;

            case BI.environment: // environment( X, Y) -- unify Y with atom value of environment variable X
              t0 = term.Arg(0);
              if (!t0.IsAtom) return false;
              string es;

              switch (t0.Functor.ToLower())
              {
            case "applicationdata":
              es = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
              break;
            case "localapplicationdata":
              es = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
              break;
            case "cookies":
              es = Environment.GetFolderPath(Environment.SpecialFolder.Cookies);
              break;
            case "desktopdirectory":
              es = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
              break;
            case "internetcache":
              es = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
              break;
            case "programfiles":
              es = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
              break;
            case "startup":
              es = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
              break;
            case "commandline":
              es = Environment.CommandLine;
              break;
            case "currentdirectory":
              es = Environment.CurrentDirectory;
              break;
            case "machinename":
              es = Environment.MachineName;
              break;
            case "newline":
              es = Environment.NewLine;
              break;
            case "osversion":
              es = Environment.OSVersion.ToString();
              break;
            case "stacktrace":
              es = Environment.StackTrace;
              break;
            case "systemdirectory":
              es = Environment.SystemDirectory;
              break;
            case "tickcount":
              es = Environment.TickCount.ToString();
              break;
            case "userdomainname":
              es = Environment.UserDomainName;
              break;
            case "userinteractive":
              es = Environment.UserInteractive.ToString();
              break;
            case "username":
              es = Environment.UserName;
              break;
            case "version":
              es = Environment.Version.ToString();
              break;
            case "workingset":
              es = Environment.WorkingSet.ToString();
              break;
            default:
              return false;
              }
              if (!term.Arg(1).Unify(new Term(es), varStack)) return false;
              break;

            case BI.query_timeout:
              t0 = term.Arg(0);
              if (t0.IsVar)
              {
            t0.Unify(new Term(queryTimeout.ToString(), FType.number), varStack);

            break;
              }
              if (!t0.IsInteger || (queryTimeout = t0.ExprValue.AsInteger) < 0) return false;
              break;

            case BI.inc_counter: // inc_counter( N) -- value of N is increased at each redo!!
              t0 = term.Arg(0);
              if (!t0.IsInteger) return false;
              t0.Functor = (t0.ExprValue.AsInteger + 1).ToString();
              break;

            //        case BI.vvv:
            //          PredicateDescr p = ps [Term.Key ("value", 2)];
            //          p.DumpClauseList ();
            //          break;

            default:
              return PrologIO.Error("Undefined built-in: {0}", term);
              }

              goalNode = goalNode.NextNode;

              if (reporting) // advance the goalList until a non-spypoint is encountered. Show spy(-exit)-info.
              {
            TermNode sp = null;

            while (goalNode is SpyPoint)
            {
              sp = ((SpyPoint)goalNode).SaveGoal;
              if (Debugger(SpyPort.exit, sp, null, false, 1)) break;
              goalNode = sp.NextNode;
            }
              }

              findFirstClause = true;

              return true;
        }
Example #26
0
        public ActionResult Test(BI.SGP.Web.Models.test t)
        {
            if (ModelState.IsValid)
            {
                if (Request.Form["id"] != null)
                {

                    t.id = int.Parse(Request.Form["id"]);
                }
                RedirectToAction("Detail");
            }

            t.id = 12;
            ViewBag.test = t;
            return View();
        }
Example #27
0
    protected void RptSIBRAdaptiveScores_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Literal     LtrStart = (Literal)e.Item.FindControl("LtrStart");
            Literal     LtrEnd   = (Literal)e.Item.FindControl("LtrEnd");
            HiddenField HdnHdnSIBRScoringTypesID = (HiddenField)e.Item.FindControl("HdnSIBRScoringTypesID");
            HiddenField HdnW = (HiddenField)e.Item.FindControl("HdnW");
            decimal.TryParse(HdnW.Value, out W);

            if (Tools.SIBRScoringTypesGroups.Motor_Skills.ToDescriptionString().Contains(string.Format(",{0},", HdnHdnSIBRScoringTypesID.Value)))
            {
                LtrStart.Visible = count == 0;
                count++;
                MS += W;
                if (count == 2)
                {
                    count          = 0;
                    LtrEnd.Visible = true;
                    MS             = Math.Round(MS / 2);
                    BI            += MS;
                    LtrMS.Text     = LtrBIMS.Text = MS._ToString();
                }
            }
            else if (Tools.SIBRScoringTypesGroups.Social_Interaction_Communication_Skills.ToDescriptionString().Contains(string.Format(",{0},", HdnHdnSIBRScoringTypesID.Value)))
            {
                if (count == 0)
                {
                    LtrStart.Visible = true;
                }
                count++;
                SC += W;
                if (count == 3)
                {
                    count          = 0;
                    LtrEnd.Visible = true;
                    SC             = Math.Round(SC / 3);
                    BI            += SC;
                    LtrSC.Text     = LtrBISC.Text = SC._ToString();
                }
            }
            else if (Tools.SIBRScoringTypesGroups.Personal_Living_Skills.ToDescriptionString().Contains(string.Format(",{0},", HdnHdnSIBRScoringTypesID.Value)))
            {
                if (count == 0)
                {
                    LtrStart.Visible = true;
                }
                count++;
                PL += W;
                if (count == 5)
                {
                    count          = 0;
                    LtrEnd.Visible = true;
                    PL             = Math.Round(PL / 5);
                    BI            += PL;
                    LtrPL.Text     = LtrBIPL.Text = PL._ToString();
                }
            }
            else if (Tools.SIBRScoringTypesGroups.Community_Living_Skills.ToDescriptionString().Contains(string.Format(",{0},", HdnHdnSIBRScoringTypesID.Value)))
            {
                if (count == 0)
                {
                    LtrStart.Visible = true;
                }
                count++;
                CL += W;
                if (count == 4)
                {
                    count          = 0;
                    LtrEnd.Visible = count == 0;
                    CL             = Math.Round(CL / 4);
                    BI            += CL;
                    LtrCL.Text     = LtrBICL.Text = CL._ToString();
                    BI             = Math.Round(BI / 4);
                    LtrBI.Text     = BI._ToString();
                }
            }
        }
    }
Example #28
0
        public static string GenerateQueryListSql(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder strControl = new StringBuilder();
            DataTable dt = DbHelperSQL.Query(field.KeyValueSource).Tables[0];
            strControl.AppendFormat("<input type='hidden' name='{0}'><select style='width:100% !important' class='chosen-select1 tag-input-style' name='{0}' id='{0}' multiple='' data-placeholder=' '><option value=''></option>", field.FieldName);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    strControl.AppendFormat("<option value='{0}'>{0}</option>", dr["Value"]);
                }
            }

            strControl.Append("</select>");

            return strControl.ToString();
        }
Example #29
0
 public static string GenerateQueryDateRange(BI.SGP.BLL.DataModels.FieldInfo field)
 {
     return String.Format("<div style='width:100% !important' class='input-group'><span class='input-group-addon'><i class='icon-calendar bigger-110'></i></span><input style='width:100% !important; height:28px' class='date-range-picker' type='text' name='{0}' id='{0}' style='cursor:pointer !important;'></div>", field.FieldName);
 }
Example #30
0
        /// <summary>
        /// 生成单个Field,返回生成的HTML代码
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public static string GenerateField(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<td style=\"background-color:#edf3f4;border:1px solid #dcebf7;width:10%;{1} \" >{0}</td>"
                , field.DisplayName
                , field.WFRequiredOption == RequiredOption.Required ? "color:red" : "color:#336199"

                );
            if (field.CategoryID == 9)
            {
                sb.AppendFormat("<td style=\"border:1px dotted #dcebf7;width:10%\" colspan={0}>", field.ColSpan);
            }
            else
            {
                sb.AppendFormat("<td style=\"border:1px dotted #dcebf7;width:15%\" colspan={0}>", field.ColSpan);
            }

            switch (field.DataType)
            {
                case "string":
                    {
                        if (field.ColSpan >= 5)
                        {
                            sb.Append(GenerateTextArea(field)); break;
                        }
                        else
                        {
                            sb.Append(GenerateTextBox(field)); break;
                        }
                    }
                case "date":
                case "datetime":
                    {
                        sb.Append(GenerateDatePicker(field)); break;
                    }
                case "time":
                    {
                        sb.Append(GenerateTimePicker(field)); break;
                    }
                case "list":
                    {
                        sb.Append(GenerateDropdownList(field)); break;
                    }
                case "listsql":
                    {
                        sb.Append(GenerateDropdownListSQL(field)); break;
                    }
                case "float":
                    {
                        sb.Append(GenerateTextBoxForCurrency(field)); break;
                    }

                case "int":
                case "double":
                    {
                        sb.Append(GenerateTextBoxForNumber(field)); break;
                    }
                case "bool":
                    {
                        sb.Append(GenerateCheckBox(field)); break;
                    }
            }

            sb.Append("</td>");

            return sb.ToString();
        }
Example #31
0
 public static string GenerateQueryExt(BI.SGP.BLL.DataModels.FieldInfo field)
 {
     if (field.FieldName == "StatusID")
     {
         return "<select class='form-control' name='StatusID' id='StatusID'><option value=''>All</option><option value='1'>New</option><option value='9'>Priced</option></select>";
     }
     return "";
 }
Example #32
0
        public static void Init()
        {
            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    var now      = DateTime.Now;
                    var showtime = new DateTime(now.Year, now.Month, now.Day + 7, 3, 30, 0);

                    Thread.Sleep(showtime - now);

                    try
                    {
                        Plugins.Feebl.Cleanup();
                    }
                    catch (Exception ex)
                    {
                        Utilities.Log.Error(ex);
                    }
                }
            });

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    try
                    {
                        Plugins.Feebl.UpdateSchedule();
                    }
                    catch (Exception ex)
                    {
                        Utilities.Log.Error(ex);
                    }

                    Thread.Sleep(Day);
                }
            });

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    try
                    {
                        Ping.ProcessWebsites();
                    }
                    catch (Exception ex)
                    {
                        Utilities.Log.Error(ex);
                    }

                    Thread.Sleep(5 * Minute);
                }
            });

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    try
                    {
                        BI.ProcessMails();
                        Plugins.Feebl.CheckDemands();
                    }
                    catch (Exception ex)
                    {
                        Utilities.Log.Error(ex);
                    }

                    Thread.Sleep(Minute);
                }
            });
        }
Example #33
0
 public static string GenerateQueryTextBox(BI.SGP.BLL.DataModels.FieldInfo field)
 {
     return String.Format("<input style='width:100% !important' id='{0}' name='{0}' type='text' onpaste='return $.bi.form.pasteJoin(this)'>", field.FieldName);
 }
Example #34
0
        public static string GenerateFieldforVertical(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder sb = new StringBuilder();

            switch (field.DataType)
            {
                case "string":
                    {
                        if (field.ColSpan >= 5)
                        {
                            sb.Append(GenerateTextArea(field)); break;
                        }
                        else
                        {
                            sb.Append(GenerateTextBox(field)); break;
                        }
                    }
                case "date":
                case "datetime":
                    {
                        sb.Append(GenerateDatePicker(field)); break;
                    }
                case "time":
                    {
                        sb.Append(GenerateTimePicker(field)); break;
                    }
                case "list":
                    {
                        sb.Append(GenerateDropdownList(field)); break;
                    }
                case "listsql":
                    {
                        sb.Append(GenerateDropdownListSQL(field)); break;
                    }
                case "float":
                case "int":
                case "double":
                    {
                        sb.Append(GenerateTextBoxForNumber(field)); break;
                    }
                case "bool":
                    {
                        sb.Append(GenerateCheckBox(field)); break;
                    }
            }

            return sb.ToString();
        }
Example #35
0
        /// <summary>
        /// 生成文本框的HTML代码
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        /// 
        public static string GenerateTextBox(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder sb = new StringBuilder();

            if (field.FieldName == "OEM" || field.FieldName == "ShipmentTerms" || field.FieldName == "Location")
            {
                sb.AppendLine(@"<input style=""width:100% !important""  id=""" + field.FieldName + @""" name=""" + field.FieldName + @"""  Value=""" + field.DataValue + @""" type=""text"" autocomplete=""off"">");
            }
            else if ((field.FieldName == "CustomerContact") && (field.DataValue == null || string.IsNullOrEmpty(field.DataValue.ToString().Trim())))
            {
                if (field.Visible == 0)
                {
                    sb.AppendLine(@"<input style=""width:100% !important""  id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" Value=""Whom it may concern"" disabled=""disabled""  type=""text""  placeholder="""" autocomplete=""off"">");
                }
                else
                {
                    sb.AppendLine(@"<input style=""width:100% !important""  id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" Value=""Whom it may concern""  type=""text""  placeholder="""" autocomplete=""off"">");
                }
            }
            else
            {
                if (field.Visible == 0)
                {
                    sb.AppendLine(@"<input style=""width:100% !important""  id=""" + field.FieldName + @""" name=""" + field.FieldName + @"""  Value=""" + field.DataValue + @""" disabled=""disabled""  type=""text""  placeholder="""" autocomplete=""off"">");
                }
                else
                {
                    sb.AppendLine(@"<input style=""width:100% !important""  id=""" + field.FieldName + @""" name=""" + field.FieldName + @"""  Value=""" + field.DataValue + @"""  type=""text""  placeholder="""" autocomplete=""off"">");
                }
            }

            return sb.ToString();
        }
Example #36
0
 public static string GenerateLabel(BI.SGP.BLL.DataModels.FieldInfo field)
 {
     StringBuilder sb = new StringBuilder();
     sb.AppendLine(@"<input id='" + field.FieldName + "' name='" + field.FieldName + @"'/>");
     return sb.ToString();
 }
Example #37
0
        public static string GenerateTextBoxForNumber(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            string val;
            double v = 0;
            if (field.DataValue == null)
            {
                field.DataValue = "";
            }
            double.TryParse(field.DataValue.ToString(), out v);

            if (v == 0)
            {
                val = "";
                if (field.FieldName == "DueDate")
                {
                    val = "48";
                }
            }
            else
            {
                val = v.ToString();
            }

            string[] hover = { "PanelSizeWidth", "PanelSizeLength" };
            StringBuilder sb = new StringBuilder();

            if (field.Visible == 0)
            {
                if (hover.Contains(field.FieldName))
                {
                    sb.Append(@"<div style=""width:100% !important""  class=""input-group""><input style=""width:100% !important""  type=""text""  disabled=""disabled"" class=""NumberType1"" id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" Value=""" + val + @""" maxlength=""8"" data-original-title=""Inches!"" data-placement=""bottom"" data-rel=""tooltip"" ></div>");
                }
                else
                {
                    sb.Append(@"<div style=""width:100% !important""  class=""input-group""><input style=""width:100% !important""  type=""text""  disabled=""disabled"" class=""NumberType1"" id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" Value=""" + val + @""" maxlength=""8""  ></div>");

                }
            }
            else
            {
                if (hover.Contains(field.FieldName))
                {
                    sb.Append(@"<div style=""width:100% !important""  class=""input-group""><input style=""width:100% !important""  type=""text"" class=""NumberType1"" id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" Value=""" + val + @""" maxlength=""8"" data-original-title=""Inches!"" data-placement=""bottom"" data-rel=""tooltip""></div>");
                }
                else
                {
                    sb.Append(@"<div style=""width:100% !important""  class=""input-group""><input style=""width:100% !important""  type=""text"" class=""NumberType1"" id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" Value=""" + val + @""" maxlength=""8""  ></div>");
                }
            }

            return sb.ToString();
        }
Example #38
0
        /// <summary>
        /// 生成打印Lable,返回生成的HTML代码
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public static string GeneratePrintField(BI.SGP.BLL.DataModels.FieldInfo field)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<td style=\"width:10%\">&nbsp;{0}</td>"
                , field.DisplayName
                );

            sb.AppendFormat("<td style=\"width:15%\" colspan={0}>", field.ColSpan);
            if (field.DataType == "float")
            {
                sb.AppendFormat(@"&nbsp;<label id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" >{0}</label>", string.Format("{0:C0}", field.DataValue));
            }
            else
            {
                sb.AppendFormat(@"&nbsp;<label id=""" + field.FieldName + @""" name=""" + field.FieldName + @""" >{0}</label>", field.DataValue);
            }

            sb.Append("</td>");

            return sb.ToString();
        }
 // builtin predicates
 public TermNode(string tag)
 {
     try
     {
       builtinId = (BI)Enum.Parse (typeof (BI), tag, false);
     }
     catch
     {
       IO.Error ("Bootstrap.cs: unknown BI enum value '{0}'", tag);
     }
 }
Example #40
0
 // builtin predicates
 public TermNode(string tag)
 {
     try
       {
     builtinId = (BI)Enum.Parse(typeof(BI), tag, false);
       }
       catch
       {
     PrologIO.Error("Unknown builtin-tag {0}", tag);
       }
 }