private void CreateRowOperators(IInputData input, IOperateRight operateRight, IEnumerable <OperatorConfig> allOperators) { var rowOperators = from item in allOperators where item.Position == OperatorPosition.Row select new Operator(item, this, input, MainResolver.GetKeyFieldArray()); DataTable operTable = rowOperators.CreateTable("RowOperator"); if (operTable == null) { return; } DataSet.Tables.Add(operTable); string rightStr = string.Empty; if (operateRight == null) { var rowRights = from item in rowOperators select item.Id; rightStr = string.Format(ObjectUtil.SysCulture, "|{0}|", string.Join("|", rowRights)); } DataTable table = DataSet.Tables[FillTableName]; DataColumn operatorColumn = table.Columns.Add("_OPERATOR_RIGHT"); foreach (DataRow row in table.Rows) { if (operateRight == null) { row[operatorColumn] = rightStr; } else { var args = new OperateRightEventArgs(input.Style, input.SourceInfo.Source, row); IEnumerable <string> rights = operateRight.GetOperator(args); if (rights != null) { rightStr = string.Join("|", rights); if (!string.IsNullOrEmpty(rightStr)) { row[operatorColumn] = "|" + rightStr + "|"; } } } } }
protected virtual void CreateListOperators(IInputData input, ref IOperateRight operateRight) { if (Operators != null) { IEnumerable <Operator> listOpertors = null; operateRight = Operators.Right.CreateObject(); if (operateRight == null) { var allOpertors = Operators.Operators; if (allOpertors != null) { listOpertors = from item in allOpertors where item.Position == OperatorPosition.Global select new Operator(item, this, input, MainResolver.GetKeyFieldArray()); } } else { IEnumerable <string> rights = operateRight.GetOperator( new OperateRightEventArgs(input.Style, input.SourceInfo.Source, null)); var allOpertors = Operators.Operators; if (rights != null && allOpertors != null) { listOpertors = from item in allOpertors join right in rights on item.Id equals right where item.Position == OperatorPosition.Global select new Operator(item, this, input, MainResolver.GetKeyFieldArray()); } } if (listOpertors != null) { DataTable table = listOpertors.CreateTable("ListOperator"); if (table != null) { DataSet.Tables.Add(table); } } } }
protected override void CreateListOperators(IInputData input, ref IOperateRight operateRight) { base.CreateListOperators(input, ref operateRight); }
protected void FillListDataSet(IInputData input, int pageNumber, int pageSize, int start) { ParamBuilderContainer condition = CreateListCondition(input); IOperateRight operateRight = null; if (TabSheets != null && TabSheets.Count > 0) { var selectedTab = GetSelectTabSheet(input); selectedTab.Selected = true; condition.Add(selectedTab.ParamBuilder); DataSet.Tables.Add(TabSheets.CreateTable("TabSheet")); } if (input.QueryString["GetData"] != "Page" && !input.IsPost) { MainResolver.FillCodeTable(input.Style); CreateListOperators(input, ref operateRight); } ListSortInfo listInfo = new ListSortInfo(input); string orderby = null; if (input.IsPost) { orderby = SetPostListInfo(input, condition, listInfo); } else { orderby = SetGetListInfo(input, condition, listInfo); } CountInfo pageInfo = CreatePageInfo(input, pageNumber, pageSize, condition); DataSet.Tables.Add(EnumUtil.Convert(pageInfo).CreateTable("Count")); DataSet.Tables.Add(EnumUtil.Convert(listInfo).CreateTable("Sort")); if (pageInfo.TotalCount <= 0) { OnFilledListTables(new FilledListEventArgs(input.IsPost, pageNumber, pageSize, pageInfo.TotalCount, orderby, MainResolver, input.PostObject, condition)); return; } int recCount = pageSize * pageNumber + start; string whereSql = condition.IsEmpty ? string.Empty : "WHERE " + condition.Sql; var listContext = FillListTable(MainResolver.ListFields, GetTableName(Context), MainResolver.GetKeyFieldArray(), whereSql, orderby, recCount, pageSize); SqlSelector selector = new SqlSelector(Context, DataSet); using (selector) { ISimpleAdapter adapter = selector; adapter.SetSql(listContext.ListSql, condition); Context.ContextConfig.SetListData(listContext, adapter, DataSet, recCount, pageSize, FillTableName); MainResolver.AddVirtualFields(); if (Operators != null) { if (operateRight == null) { operateRight = Operators.Right.CreateObject(); } var allOperators = Operators.Operators; if (allOperators != null) { CreateRowOperators(input, operateRight, allOperators); } } MainResolver.Decode(input.Style); OnFilledListTables(new FilledListEventArgs(input.IsPost, pageNumber, pageSize, pageInfo.TotalCount, orderby, MainResolver, input.PostObject, condition)); } }