protected void Page_Load(object sender, EventArgs e) { var cond = new Cond(); if (cond.Retrieve(CondAttr.NodeID, this.FK_Node, CondAttr.ToNodeID, int.Parse(this.ToFlow)) != 0) { CurrentCond = DataFrom[cond.HisDataFrom]; } }
internal override Node Bind(Binder b) { b.OpenScope(); b.Bind(ref Cond); Cond.RequireGetAccess(); b.Convert(ref Cond, Compilation.Get(NativeType.Boolean)); b.Bind(ref Stmt); b.CloseScope(); return(null); }
public override string ToString() { string res = "if (" + Cond.ToString() + ")" + Environment.NewLine + If.ToString(); if (Else != null) { res += Environment.NewLine + "else" + Environment.NewLine + Else.ToString(); } return(res); }
internal void Emit(ILGenerator ilg, Label end) { Cond.Emit(ilg, true); var lf = ilg.DefineLabel(); ilg.Emit(OpCodes.Brfalse, lf); Stmt.Emit(ilg); ilg.Emit(OpCodes.Br, end); ilg.MarkLabel(lf); }
public void TestJoin() { Select sel = Qb.Select("a").From("lt").Join("rt", JoinCond.Fields("id_0")); From lt = From.Table("lt"); From rt = From.Table("rt"); Logic l = Logic.And(Cond.Equal(Expr.Field("id_0", lt), Expr.Field("id_0", rt))); sel = Qb.Select("a").From("lt").Join(JoinType.Left, lt, rt, l); }
public override string ToString() { string res = "if (" + Cond.ToString() + ")\n" + If.ToString(); if (Else != null) { res += "\nelse\n" + Else.ToString(); } return(res); }
/// <summary> /// Add condition on WHERE clause. /// </summary> /// <param name="condition"></param> /// <returns></returns> public virtual M<TDbConn, TDbParam> Where(Cond<TDbParam> condition) { var condSql = (condition == null ? string.Empty : condition.FetchSql()); if (string.IsNullOrEmpty(condSql)) return this; WhereConditions.Add(condSql); if (condition != null) DbParams.AddRange(condition.FetchDbParams()); CachedSelectSql = string.Empty; return this; }
internal override void Emit(ILGenerator ilg, Label end) { Cond.Emit(ilg, true); ilg.Emit(OpCodes.Brfalse, Exit(ilg)); if (When != null) { When.Emit(ilg, true); ilg.Emit(OpCodes.Brfalse, Exit(ilg)); } base.Emit(ilg, end); }
protected void Page_Load(object sender, EventArgs e) { Cond cond = new Cond(); cond.MyPK = this.GenerMyPK; cond.RetrieveFromDBSources(); this.AddTable("class='Table' cellSpacing='1' cellPadding='1' border='1' style='width:100%'"); this.AddTR(); this.AddTD("class='GroupTitle'", "设置SQL"); this.AddTREnd(); AddTR(); TextBox tb = new TextBox(); tb.ID = "TB_SQL"; tb.TextMode = TextBoxMode.MultiLine; tb.Rows = 10; tb.Columns = 80; tb.Style.Add("width", "99%"); tb.Text = cond.OperatorValueStr; AddTD("", tb); AddTREnd(); AddTableEnd(); AddBR(); AddSpace(1); var btn = new LinkBtn(false, NamesOfBtn.Save, "保存"); btn.Click += new EventHandler(btn_Click); this.Add(btn); AddSpace(1); btn = new LinkBtn(false, NamesOfBtn.Delete, "删除"); btn.Attributes["onclick"] = " return confirm('您确定要删除吗?');"; btn.Click += new EventHandler(btn_Click); this.Add(btn); AddBR(); AddBR(); string help = ""; help += "<ul>"; help += "<li>在文本框里设置一个查询SQL,它返回一行一列。比如: SELECT COUNT(*) AS Num FROM MyTable WHERE NAME='@MyFieldName'。 </li>"; help += "<li>该SQL参数支持系统的表达式,什么是ccflow的表达式请查看说明书。</li>"; help += "<li>当前登录信息变量: @WebUser.No, @WebUser.Name, @WebUser.FK_Dept.</li>"; help += "<li>系统就会获取该返回的值把它转化为decimal类型</li>"; help += "<li>如果该值大于零,该条件就是成立的否则不成立。</li>"; help += "</ul>"; AddEasyUiPanelInfo("帮助", help); }
internal override void EmitStmt(ILGenerator ilg) { Begin = ilg.DefineLabel(); End = ilg.DefineLabel(); ilg.MarkLabel(Begin); Cond.Emit(ilg, true); ilg.Emit(OpCodes.Brfalse, End); Stmt.Emit(ilg); ilg.Emit(OpCodes.Br, Begin); ilg.MarkLabel(End); }
// Composite Nodes public static Leaf Selector(Cond cond, Leaf ifTrue, Leaf ifFalse) { if (cond()) { return(ifTrue); } else { return(ifFalse); } }
public void TestCond() { Cond c = Cond.Equal(Expr.Field("a"), Expr.Param("p")); c = Cond.Like(Expr.Field("a"), Expr.Param("p"), '!'); c = Cond.Like("a", "%"); c = Cond.In(Expr.Field("a"), Qb.Select("a")); c = Cond.IsNull(Expr.Field("a")); c = Cond.Between(Expr.Field("a"), Expr.Param("p1"), Expr.Param("p2")); c = Cond.Exists(Qb.Select("a")); }
/// <summary> /// Returns a copy (clone) of this object /// </summary> public override object Clone() { ConditionList Clone = new ConditionList(this.Type); foreach (Condition Cond in SubConditions) { Clone.Add(Cond.Clone() as Condition); } return(Clone as object); }
/// <summary> /// 保存 /// </summary> /// <returns></returns> public string CondByStation_Save() { int FK_MainNode = this.GetRequestValInt("FK_MainNode"); int ToNodeID = this.GetRequestValInt("ToNodeID"); CondType HisCondType = CondType.Dir; Cond cond = new Cond(); cond.Delete(CondAttr.NodeID, FK_MainNode, CondAttr.ToNodeID, ToNodeID, CondAttr.CondType, (int)HisCondType); string mypk = FK_MainNode + "_" + ToNodeID + "_Dir_" + ConnDataFrom.Stas.ToString(); //把其他的条件都删除掉. DBAccess.RunSQL("DELETE FROM WF_Cond WHERE (CondType=" + (int)HisCondType + " AND NodeID=" + this.FK_Node + " AND ToNodeID=" + ToNodeID + ") AND DataFrom!=" + (int)ConnDataFrom.Stas); // 删除岗位条件. cond.MyPK = mypk; if (cond.RetrieveFromDBSources() == 0) { cond.HisDataFrom = ConnDataFrom.Stas; cond.NodeID = FK_MainNode; cond.FK_Flow = this.FK_Flow; cond.ToNodeID = ToNodeID; cond.Insert(); } string val = this.GetRequestVal("emps").Replace(",", "@"); string valT = this.GetRequestVal("orgEmps").Replace(",", " "); cond.OperatorValue = val; //cond.OperatorValueT = valT; cond.SetPara("OrgEmps", valT); cond.SpecOperWay = (SpecOperWay)this.GetRequestValInt("DDL_SpecOperWay"); if (cond.SpecOperWay != SpecOperWay.CurrOper) { cond.SpecOperPara = this.GetRequestVal("TB_SpecOperPara"); } else { cond.SpecOperPara = string.Empty; } cond.HisDataFrom = ConnDataFrom.Stas; cond.FK_Flow = this.FK_Flow; cond.HisCondType = CondType.Dir; cond.FK_Node = FK_MainNode; cond.ToNodeID = ToNodeID; cond.Update(); return("保存成功.."); }
/// <summary> /// 初始化Init. /// </summary> /// <returns></returns> public string Condition_Init() { string toNodeID = this.GetRequestVal("ToNodeID"); var cond = new Cond(); cond.Retrieve(CondAttr.NodeID, this.FK_Node, CondAttr.ToNodeID, toNodeID); cond.Row.Add("HisDataFrom", cond.HisDataFrom.ToString()); // cond.HisDataFrom //CurrentCond = DataFrom[cond.HisDataFrom]; return(cond.ToJson()); }
protected void Page_Load(object sender, EventArgs e) { this.Page.Title = "部门条件"; if (this.Request.QueryString["DoType"] == "Del") { Cond nd = new Cond(this.MyPK); nd.Delete(); this.Response.Redirect("CondDept.aspx?CondType=" + (int)this.HisCondType + "&FK_Flow=" + this.FK_Flow + "&FK_MainNode=" + nd.NodeID + "&FK_Node=" + this.FK_MainNode + "&ToNodeID=" + nd.ToNodeID, true); return; } this.BindCond(); }
internal override Node Bind(Binder b) { b.Bind(ref Cond); b.Bind(ref True); b.Bind(ref False); Cond.RequireGetAccess(); True.RequireGetAccess(); False.RequireGetAccess(); b.Convert(ref Cond, Compilation.Get(NativeType.Boolean)); Datatype = b.ConvertResult(ref True, ref False); return(null); }
public static CondAsync <A, D> SelectMany <A, B, C, D>( this Cond <A, B> self, Func <B, CondAsync <A, C> > bind, Func <B, C, D> project) => input => from b in self.ToAsync()(input) from c in b.Match( Some: b1 => bind(b1)(input), None: () => Option <C> .None.AsTask()) select(from x in b from y in c select project(x, y));
public INSql Where(Action <INSql> SubCondition, Cond condition = Cond.AND) { var condtion = new Condition() { SubCondition = SubCondition, ConditionValue = condition }; this.ListConditionWheres.Add(condtion); return(this); }
public INSql Having(INSql subquery, Cond condition = Cond.AND) { var cond = new Condition() { Operator = Op.Raw, Raw = String.Format("( {0} )", subquery.ToSql()) }; this.ListConditionHavings.Add(cond); return(this); }
public void TestDelete() { Delete del = Qb.Delete("Customers") .Where(Cond.Equal("Id", 20)); Renderer.SqlServerRenderer renderer = new Renderer.SqlServerRenderer(); string sql = renderer.RenderDelete(del); del = Qb.Delete("Customers", "nsi") .Where(Cond.Equal("Id", 20)); sql = renderer.RenderDelete(del); }
void btn_Click(object sender, EventArgs e) { Cond cond = new Cond(); cond.Delete(CondAttr.ToNodeID, this.ToNodeID, CondAttr.DataFrom, (int)ConnDataFrom.SQL); Button btn = sender as Button; if (btn.ID == "Btn_Del") { this.Response.Redirect(this.Request.RawUrl, true); return; } string sql = this.GetTextBoxByID("TB_SQL").Text; if (string.IsNullOrEmpty(sql)) { this.Alert("请填写sql语句."); return; } cond.MyPK = this.GenerMyPK; cond.HisDataFrom = ConnDataFrom.SQL; cond.NodeID = this.FK_MainNode; cond.FK_Node = this.FK_MainNode; cond.FK_Flow = this.FK_Flow; cond.ToNodeID = this.ToNodeID; cond.OperatorValue = sql; cond.FK_Flow = this.FK_Flow; cond.HisCondType = this.HisCondType; cond.Insert(); this.Alert("保存成功"); //switch (this.HisCondType) //{ // case CondType.Flow: // case CondType.Node: // cond.Update(); // this.Response.Redirect("CondDept.aspx?MyPK=" + cond.MyPK + "&FK_Flow=" + cond.FK_Flow + "&FK_Node=" + cond.FK_Node + "&FK_MainNode=" + cond.NodeID + "&CondType=" + (int)cond.HisCondType + "&FK_Attr=" + cond.FK_Attr, true); // return; // case CondType.Dir: // cond.ToNodeID = this.ToNodeID; // cond.Update(); // this.Response.Redirect("CondDept.aspx?MyPK=" + cond.MyPK + "&FK_Flow=" + cond.FK_Flow + "&FK_Node=" + cond.FK_Node + "&FK_MainNode=" + cond.NodeID + "&CondType=" + (int)cond.HisCondType + "&FK_Attr=" + cond.FK_Attr + "&ToNodeID=" + this.Request.QueryString["ToNodeID"], true); // return; // default: // throw new Exception("未设计的情况。"); //} }
protected void Page_Load(object sender, EventArgs e) { Cond cond = new Cond(); cond.MyPK = this.GenerMyPK; cond.RetrieveFromDBSources(); this.AddTable("class='Table' cellSpacing='1' cellPadding='1' border='1' style='width:100%'"); this.AddTR(); this.AddTD("class='GroupTitle'", "设置CCFlow要求格式的系统参数"); this.AddTREnd(); TextBox tb = new TextBox(); tb.ID = "TB_Para"; tb.TextMode = TextBoxMode.MultiLine; tb.Rows = 1; tb.Columns = 80; tb.Style.Add("width", "99%"); tb.Text = cond.OperatorValueStr; AddTD("", tb); AddTREnd(); AddTableEnd(); AddBR(); AddSpace(1); var btn = new LinkBtn(false, NamesOfBtn.Save, "保存"); btn.Click += new EventHandler(btn_Click); this.Add(btn); AddSpace(1); btn = new LinkBtn(false, NamesOfBtn.Delete, "删除"); btn.Attributes["onclick"] = " return confirm('您确定要删除吗?');"; btn.Click += new EventHandler(btn_Click); this.Add(btn); AddBR(); AddBR(); AddEasyUiPanelInfo("说明", "表达式格式:参数+空格+操作符+空格+值,仅支持一个表达式。格式如下:<br />" + Environment.NewLine + "<ul>" + Environment.NewLine + "<li>Emp = zhangsan</li>" + Environment.NewLine + "<li>JinE = 30</li>" + Environment.NewLine + "<li>JinE >= 30</li>" + Environment.NewLine + "<li>JinE > 30</li>" + Environment.NewLine + "<li>Way = '1'</li>" + Environment.NewLine + "<li>Way != '1'</li>" + Environment.NewLine + "<li>Name LIKE %li%</li>" + Environment.NewLine + "</ul>" + Environment.NewLine); }
public void Solve() { int N = NextInt(); int cnt = 0; var A = IntList(); if (N == 1) { 1.WL(); return; } Func <int, int, Cond> getDirection = (x, y) => { return(A[x] < A[y] ? Cond.UE : A[x] == A[y] ? Cond.WAKARAN : Cond.SITA); }; Cond cond = getDirection(0, 1); for (int i = 1; i < N - 1; i++) { switch (cond) { case Cond.UE: if (A[i] > A[i + 1]) { cond = Cond.WAKARAN; cnt++; } break; case Cond.SITA: if (A[i] < A[i + 1]) { cond = Cond.WAKARAN; cnt++; } break; case Cond.WAKARAN: cond = getDirection(i, i + 1); break; default: break; } } cnt++; cnt.WL(); return; }
internal override void EmitStmt(ILGenerator ilg) { Cond.Emit(ilg, true); var lb = ilg.DefineLabel(); var le = ilg.DefineLabel(); ilg.Emit(OpCodes.Brtrue, lb); StmtElse?.Emit(ilg); ilg.Emit(OpCodes.Br, le); ilg.MarkLabel(lb); StmtIf?.Emit(ilg); ilg.MarkLabel(le); }
public INSql WhereFindInSet(string column, string value, Cond condition = Cond.AND) { var cond = new Condition() { Operator = Op.FindInSet, ConditionValue = condition, Column = column, Value = value }; this.ListConditionWheres.Add(cond); return(this); }
public INSql WhereFindInSet(string column, List <object> values, Cond condition = Cond.AND) { var cond = new Condition() { Operator = Op.FindInSet, ConditionValue = condition, Column = column, Value = ConvertToIn(values) }; this.ListConditionWheres.Add(cond); return(this); }
public INSql WhereRaw(string sql, Cond condition = Cond.AND) { var cond = new Condition() { Operator = Op.Raw, Raw = sql }; this.ListConditionWheres.Add(cond); return(this); }
private void SetTemperDevice() { if (Auto) { Heat.SetInitialTemperature(); Cond.SetInitialTemperature(); } else { Heat.SetTemperature(Temperature); Cond.SetTemperature(Temperature); } }
public void AbsorbtionAddsAllClauses() { Assert.AreEqual( 3, Cond.If(false).Then(0) .If(false).Then(1) .Absorb( Cond.If(false).Then(2) .If(true).Then(3) .If(false).Then(4)) .If(false).Then(5) .Else(-1)); }
public Sense(string[] elems) { Debug.Assert(elems.Length >= 4); string d = elems[1].ToLower(); if (d == "here") dir = Dir.Here; else if (d == "ahead") dir = Dir.Ahead; else if (d == "leftahead") dir = Dir.LeftAhead; else if (d == "rightahead") dir = Dir.RightAhead; else Debug.Assert(false); trueState = Int32.Parse(elems[2]); falseState = Int32.Parse(elems[3]); string c = elems[4].ToLower(); if (c == "friend") cond = Cond.Friend; else if (c == "foe") cond = Cond.Foe; else if (c == "friendwithfood") cond = Cond.FriendWithFood; else if (c == "foewithfood") cond = Cond.FoeWithFood; else if (c == "food") cond = Cond.Food; else if (c == "rock") cond = Cond.Rock; else if (c == "home") cond = Cond.Home; else if (c == "foehome") cond = Cond.FoeHome; else if (c == "foemarker") cond = Cond.FoeMarker; else if (c == "marker") cond = Cond.Marker + Int32.Parse(elems[5]); else Debug.Assert(false); }