예제 #1
0
        private static List <int> GetSwitchTargets(SiteSettings ss, int deptId)
        {
            var view = Views.GetBySession(ss);

            var where = view.Where(ss: ss, where : Rds.DeptsWhere().TenantId(Sessions.TenantId()));
            var switchTargets = Rds.ExecuteScalar_int(statements:
                                                      Rds.SelectDepts(
                                                          column: Rds.DeptsColumn().DeptsCount(),
                                                          where : where)) <= Parameters.General.SwitchTargetsLimit
                        ? Rds.ExecuteTable(statements: Rds.SelectDepts(
                                               column: Rds.DeptsColumn().DeptId(),
                                               where : where,
                                               orderBy: view.OrderBy(ss, Rds.DeptsOrderBy()
                                                                     .UpdatedTime(SqlOrderBy.Types.desc))))
                                .AsEnumerable()
                                .Select(o => o["DeptId"].ToInt())
                                .ToList()
                        : new List <int>();

            if (!switchTargets.Contains(deptId))
            {
                switchTargets.Add(deptId);
            }
            return(switchTargets);
        }
예제 #2
0
        private EnumerableRowCollection <DataRow> Depts(
            Context context,
            SiteSettings ss,
            long inheritPermission,
            string searchText,
            bool setAllChoices,
            int offset)
        {
            var view = GetView(
                context: context,
                ss: ss);
            var sqlColumn = SetSqlColum(
                context: context,
                ss: ss,
                keyColumnName: "DeptId",
                textColumnName: "DeptName");
            var dataRows = Rds.ExecuteTable(
                context: context,
                statements: Rds.SelectDepts(
                    column: sqlColumn,
                    where : view.Where(
                        context: context,
                        ss: ss,
                        where : Rds.DeptsWhere()
                        .TenantId(context.TenantId)
                        .SiteDeptWhere(
                            context: context,
                            siteId: inheritPermission,
                            _using: MembersOnly == true)
                        .SqlWhereLike(
                            tableName: "Depts",
                            name: "SearchText",
                            searchText: searchText,
                            clauseCollection: new List <string>()
            {
                Rds.Depts_DeptId_WhereLike(factory: context),
                Rds.Depts_DeptName_WhereLike(factory: context),
                Rds.Depts_Body_WhereLike(factory: context)
            })),
                    orderBy: view.OrderBy(
                        context: context,
                        ss: ss,
                        orderBy: view.ColumnSorterHash?.Any() != true
                            ? Rds.DeptsOrderBy().DeptName()
                            : null),
                    offset: offset,
                    pageSize: !setAllChoices
                        ? Parameters.General.DropDownSearchPageSize
                        : 0))
                           .AsEnumerable();

            return(dataRows);
        }
예제 #3
0
 private static DeptCollection DeptCollection(
     SiteSettings ss, View view, int offset = 0)
 {
     return(new DeptCollection(
                ss: ss,
                column: GridSqlColumnCollection(ss),
                where : view.Where(ss, Rds.DeptsWhere().TenantId(Sessions.TenantId())),
                orderBy: view.OrderBy(ss, Rds.DeptsOrderBy()
                                      .UpdatedTime(SqlOrderBy.Types.desc)),
                offset: offset,
                pageSize: ss.GridPageSize.ToInt(),
                countRecord: true,
                aggregationCollection: ss.Aggregations));
 }
예제 #4
0
        public static string Histories(SiteSettings ss, int deptId)
        {
            var deptModel = new DeptModel(ss, deptId);

            ss.SetColumnAccessControls(deptModel.Mine());
            var columns = ss.GetHistoryColumns(checkPermission: true);

            if (!ss.CanRead())
            {
                return(Error.Types.HasNotPermission.MessageJson());
            }
            var hb = new HtmlBuilder();

            hb.Table(
                attributes: new HtmlAttributes().Class("grid"),
                action: () => hb
                .THead(action: () => hb
                       .GridHeader(
                           columns: columns,
                           sort: false,
                           checkRow: false))
                .TBody(action: () =>
                       new DeptCollection(
                           ss: ss,
                           column: HistoryColumn(columns),
                           where : Rds.DeptsWhere().DeptId(deptModel.DeptId),
                           orderBy: Rds.DeptsOrderBy().Ver(SqlOrderBy.Types.desc),
                           tableType: Sqls.TableTypes.NormalAndHistory)
                       .ForEach(deptModelHistory => hb
                                .Tr(
                                    attributes: new HtmlAttributes()
                                    .Class("grid-row history not-link")
                                    .DataAction("History")
                                    .DataMethod("post")
                                    .DataVer(deptModelHistory.Ver)
                                    .DataLatest(1, _using:
                                                deptModelHistory.Ver == deptModel.Ver),
                                    action: () => columns
                                    .ForEach(column => hb
                                             .TdValue(
                                                 ss: ss,
                                                 column: column,
                                                 deptModel: deptModelHistory))))));
            return(new DeptsResponseCollection(deptModel)
                   .Html("#FieldSetHistories", hb).ToJson());
        }
예제 #5
0
 private static void HistoriesTableBody(
     this HtmlBuilder hb,
     Context context,
     SiteSettings ss,
     List <Column> columns,
     DeptModel deptModel)
 {
     new DeptCollection(
         context: context,
         ss: ss,
         column: HistoryColumn(columns),
         where : Rds.DeptsWhere().DeptId(deptModel.DeptId),
         orderBy: Rds.DeptsOrderBy().Ver(SqlOrderBy.Types.desc),
         tableType: Sqls.TableTypes.NormalAndHistory)
     .ForEach(deptModelHistory => hb
              .Tr(
                  attributes: new HtmlAttributes()
                  .Class("grid-row")
                  .DataAction("History")
                  .DataMethod("post")
                  .DataVer(deptModelHistory.Ver)
                  .DataLatest(1, _using:
                              deptModelHistory.Ver == deptModel.Ver),
                  action: () =>
     {
         hb.Td(
             css: "grid-check-td",
             action: () => hb
             .CheckBox(
                 controlCss: "grid-check",
                 _checked: false,
                 dataId: deptModelHistory.Ver.ToString(),
                 _using: deptModelHistory.Ver < deptModel.Ver));
         columns
         .ForEach(column => hb
                  .TdValue(
                      context: context,
                      ss: ss,
                      column: column,
                      deptModel: deptModelHistory));
     }));
 }