private static HtmlBuilder TdCustomValue(
            this HtmlBuilder hb,
            Context context,
            SiteSettings ss,
            string gridDesign,
            TenantModel tenantModel)
        {
            ss.IncludedColumns(gridDesign).ForEach(column =>
            {
                var value = string.Empty;
                switch (column.Name)
                {
                case "Ver": value = tenantModel.Ver.GridText(
                        context: context,
                        column: column); break;

                case "Comments": value = tenantModel.Comments.GridText(
                        context: context,
                        column: column); break;

                case "Creator": value = tenantModel.Creator.GridText(
                        context: context,
                        column: column); break;

                case "Updator": value = tenantModel.Updator.GridText(
                        context: context,
                        column: column); break;

                case "CreatedTime": value = tenantModel.CreatedTime.GridText(
                        context: context,
                        column: column); break;

                case "UpdatedTime": value = tenantModel.UpdatedTime.GridText(
                        context: context,
                        column: column); break;
                }
                gridDesign = gridDesign.Replace("[" + column.ColumnName + "]", value);
            });
            return(hb.Td(action: () => hb
                         .Div(css: "markup", action: () => hb
                              .Text(text: gridDesign))));
        }
 private static void HistoriesTableBody(
     this HtmlBuilder hb,
     Context context,
     SiteSettings ss,
     List <Column> columns,
     TenantModel tenantModel)
 {
     new TenantCollection(
         context: context,
         ss: ss,
         column: HistoryColumn(columns),
         where : Rds.TenantsWhere().TenantId(tenantModel.TenantId),
         orderBy: Rds.TenantsOrderBy().Ver(SqlOrderBy.Types.desc),
         tableType: Sqls.TableTypes.NormalAndHistory)
     .ForEach(tenantModelHistory => hb
              .Tr(
                  attributes: new HtmlAttributes()
                  .Class("grid-row")
                  .DataAction("History")
                  .DataMethod("post")
                  .DataVer(tenantModelHistory.Ver)
                  .DataLatest(1, _using:
                              tenantModelHistory.Ver == tenantModel.Ver),
                  action: () =>
     {
         hb.Td(
             css: "grid-check-td",
             action: () => hb
             .CheckBox(
                 controlCss: "grid-check",
                 _checked: false,
                 dataId: tenantModelHistory.Ver.ToString(),
                 _using: tenantModelHistory.Ver < tenantModel.Ver));
         columns
         .ForEach(column => hb
                  .TdValue(
                      context: context,
                      ss: ss,
                      column: column,
                      tenantModel: tenantModelHistory));
     }));
 }
Пример #3
0
 public static ErrorData OnDeleting(
     Context context, SiteSettings ss, TenantModel tenantModel, bool api = false)
 {
     if (api)
     {
         if ((context.ContractSettings.Api == false || !Parameters.Api.Enabled))
         {
             return(new ErrorData(type: Error.Types.InvalidRequest));
         }
         if (context.InvalidJsonData)
         {
             return(new ErrorData(type: Error.Types.InvalidJsonData));
         }
     }
     return(context.CanDelete(ss: ss) && !tenantModel.ReadOnly
         ? new ErrorData(type: Error.Types.None)
         : !context.CanRead(ss: ss)
             ? new ErrorData(type: Error.Types.NotFound)
             : new ErrorData(type: Error.Types.HasNotPermission));
 }
Пример #4
0
        public static string Editor(
            Context context, SiteSettings ss, TenantModel tenantModel)
        {
            var invalid = TenantValidators.OnEditing(
                context: context,
                ss: ss,
                tenantModel: tenantModel);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(HtmlTemplates.Error(context, invalid));
            }
            var hb = new HtmlBuilder();

            ss.SetColumnAccessControls(
                context: context,
                mine: tenantModel.Mine(context: context));
            return(hb.Template(
                       context: context,
                       ss: ss,
                       view: null,
                       verType: tenantModel.VerType,
                       methodType: tenantModel.MethodType,
                       referenceType: "Tenants",
                       title: tenantModel.MethodType == BaseModel.MethodTypes.New
                    ? Displays.Tenants(context: context) + " - " + Displays.New(context: context)
                    : tenantModel.Title.Value,
                       action: () =>
            {
                hb
                .Editor(
                    context: context,
                    ss: ss,
                    tenantModel: tenantModel)
                .Hidden(controlId: "TableName", value: "Tenants")
                .Hidden(controlId: "Controller", value: context.Controller)
                .Hidden(controlId: "Id", value: tenantModel.TenantId.ToString());
            }).ToString());
        }
Пример #5
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string UpdateTenantImage(Context context, TenantModel tenantModel)
        {
            var ss      = SiteSettingsUtilities.TenantsSiteSettings(context);
            var bin     = context.PostedFiles.FirstOrDefault()?.Byte();
            var invalid = BinaryValidators.OnUploadingTenantImage(
                context: context,
                ss: ss,
                bin: bin);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson(context: context));
            }
            var error = new BinaryModel(tenantModel.TenantId).UpdateTenantImage(
                context: context,
                ss: ss,
                bin: bin);

            if (error.Has())
            {
                return(error.MessageJson(context: context));
            }
            else
            {
                return(new ResponseCollection()
                       .ReplaceAll(
                           "#Logo",
                           new HtmlBuilder().HeaderLogo(
                               context: context,
                               ss: ss))
                       .ReplaceAll(
                           "#TenantImageSettingsEditor",
                           new HtmlBuilder().TenantImageSettingsEditor(
                               context: context, tenantModel: tenantModel))
                       .Message(Messages.FileUpdateCompleted(context: context))
                       .ToJson());
            }
        }
        public static ErrorData OnEditing(
            Context context, SiteSettings ss, TenantModel tenantModel, bool api = false)
        {
            if (api)
            {
                if ((!Parameters.Api.Enabled ||
                     context.ContractSettings.Api == false ||
                     context.UserSettings?.AllowApi(context: context) == false))
                {
                    return(new ErrorData(type: Error.Types.InvalidRequest));
                }
                if (context.InvalidJsonData)
                {
                    return(new ErrorData(type: Error.Types.InvalidJsonData));
                }
            }
            if (ss.GetNoDisplayIfReadOnly())
            {
                return(new ErrorData(type: Error.Types.NotFound));
            }
            switch (tenantModel.MethodType)
            {
            case BaseModel.MethodTypes.Edit:
                return
                    (context.CanRead(ss: ss) &&
                     tenantModel.AccessStatus != Databases.AccessStatuses.NotFound
                            ? new ErrorData(type: Error.Types.None)
                            : new ErrorData(type: Error.Types.NotFound));

            case BaseModel.MethodTypes.New:
                return(context.CanCreate(ss: ss)
                        ? new ErrorData(type: Error.Types.None)
                        : !context.CanRead(ss: ss)
                            ? new ErrorData(type: Error.Types.NotFound)
                            : new ErrorData(type: Error.Types.HasNotPermission));

            default:
                return(new ErrorData(type: Error.Types.NotFound));
            }
        }
Пример #7
0
        public static string Create(Context context, SiteSettings ss)
        {
            var tenantModel = new TenantModel(context, ss, 0, setByForm: true);
            var invalid     = TenantValidators.OnCreating(
                context: context,
                ss: ss,
                tenantModel: tenantModel);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson(context: context));
            }
            var error = tenantModel.Create(context: context, ss: ss);

            switch (error)
            {
            case Error.Types.None:
                SessionUtilities.Set(
                    context: context,
                    message: Messages.Created(
                        context: context,
                        data: tenantModel.Title.Value));
                return(new ResponseCollection()
                       .Response("id", tenantModel.TenantId.ToString())
                       .SetMemory("formChanged", false)
                       .Href(Locations.Edit(
                                 context: context,
                                 controller: context.Controller,
                                 id: ss.Columns.Any(o => o.Linking)
                                ? context.Forms.Long("LinkId")
                                : tenantModel.TenantId))
                       .ToJson());

            default:
                return(error.MessageJson(context: context));
            }
        }
Пример #8
0
        public static string Histories(
            Context context, SiteSettings ss, int tenantId, Message message = null)
        {
            var tenantModel = new TenantModel(context: context, ss: ss, tenantId: tenantId);

            ss.SetColumnAccessControls(
                context: context,
                mine: tenantModel.Mine(context: context));
            var columns = ss.GetHistoryColumns(context: context, checkPermission: true);

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

            hb
            .HistoryCommands(context: context, ss: ss)
            .Table(
                attributes: new HtmlAttributes().Class("grid history"),
                action: () => hb
                .THead(action: () => hb
                       .GridHeader(
                           context: context,
                           columns: columns,
                           sort: false,
                           checkRow: true))
                .TBody(action: () => hb
                       .HistoriesTableBody(
                           context: context,
                           ss: ss,
                           columns: columns,
                           tenantModel: tenantModel)));
            return(new TenantsResponseCollection(tenantModel)
                   .Html("#FieldSetHistories", hb)
                   .Message(message)
                   .ToJson());
        }
Пример #9
0
        public static string Delete(Context context, SiteSettings ss, int tenantId)
        {
            var tenantModel = new TenantModel(context, ss, tenantId);
            var invalid     = TenantValidators.OnDeleting(
                context: context,
                ss: ss,
                tenantModel: tenantModel);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson(context: context));
            }
            var error = tenantModel.Delete(context: context, ss: ss);

            switch (error)
            {
            case Error.Types.None:
                SessionUtilities.Set(
                    context: context,
                    message: Messages.Deleted(
                        context: context,
                        data: tenantModel.Title.Value));
                var res = new TenantsResponseCollection(tenantModel);
                res
                .SetMemory("formChanged", false)
                .Href(Locations.Index(
                          context: context,
                          controller: "Tenants"));
                return(res.ToJson());

            default:
                return(error.MessageJson(context: context));
            }
        }
Пример #10
0
 private static ResponseCollection ResponseByUpdate(
     TenantsResponseCollection res,
     Context context,
     SiteSettings ss,
     TenantModel tenantModel)
 {
     if (context.Forms.Bool("IsDialogEditorForm"))
     {
         var view = Views.GetBySession(
             context: context,
             ss: ss,
             setSession: false);
         var gridData = new GridData(
             context: context,
             ss: ss,
             view: view,
             where : Rds.TenantsWhere().TenantId(tenantModel.TenantId));
         var columns = ss.GetGridColumns(
             context: context,
             view: view,
             checkPermission: true);
         return(res
                .ReplaceAll(
                    $"[data-id=\"{tenantModel.TenantId}\"]",
                    gridData.TBody(
                        hb: new HtmlBuilder(),
                        context: context,
                        ss: ss,
                        columns: columns,
                        checkAll: false))
                .CloseDialog()
                .Message(Messages.Updated(
                             context: context,
                             data: tenantModel.Title.DisplayValue)));
     }
     else
     {
         return(res
                .Ver(context: context, ss: ss)
                .Timestamp(context: context, ss: ss)
                .FieldResponse(context: context, ss: ss, tenantModel: tenantModel)
                .Val("#VerUp", false)
                .Disabled("#VerUp", false)
                .Html("#HeaderTitle", tenantModel.Title.Value)
                .Html("#RecordInfo", new HtmlBuilder().RecordInfo(
                          context: context,
                          baseModel: tenantModel,
                          tableName: "Tenants"))
                .SetMemory("formChanged", false)
                .Message(Messages.Updated(
                             context: context,
                             data: tenantModel.Title.Value))
                .Comment(
                    context: context,
                    ss: ss,
                    column: ss.GetColumn(context: context, columnName: "Comments"),
                    comments: tenantModel.Comments,
                    deleteCommentId: tenantModel.DeleteCommentId)
                .ClearFormData());
     }
 }
Пример #11
0
        /// <summary>
        /// Fixed:
        /// </summary>
        private static HtmlBuilder FieldSetGeneralColumns(
            this HtmlBuilder hb,
            Context context,
            SiteSettings ss,
            TenantModel tenantModel,
            bool preview = false)
        {
            var title           = ss.GetColumn(context, "Title");
            var logoType        = ss.GetColumn(context, "LogoType");
            var htmlTitleTop    = ss.GetColumn(context, "HtmlTitleTop");
            var htmlTitleSite   = ss.GetColumn(context, "HtmlTitleSite");
            var htmlTitleRecord = ss.GetColumn(context, "HtmlTitleRecord");

            return(hb.FieldSet(id: "FieldSetGeneral", action: () => hb
                               .Field(
                                   context: context,
                                   ss: ss,
                                   column: title,
                                   methodType: tenantModel.MethodType,
                                   value: tenantModel.Title
                                   .ToControl(context: context, ss: ss, column: title),
                                   columnPermissionType: title.ColumnPermissionType(context: context))
                               .FieldDropDown(
                                   context: context,
                                   controlId: "Tenants_LogoType",
                                   controlCss: " always-send",
                                   labelText: Displays.TenantImageType(context),
                                   optionCollection: new Dictionary <string, string>()
            {
                [TenantModel.LogoTypes.ImageOnly.ToInt().ToString()] = Displays.ImageOnly(context),
                [TenantModel.LogoTypes.ImageAndTitle.ToInt().ToString()] = Displays.ImageAndText(context)
            }
                                   , selectedValue: tenantModel.LogoType.ToInt().ToString())
                               .TenantImageSettingsEditor(context, tenantModel)
                               .FieldSet(
                                   id: "HtmlTitleSettingsField",
                                   css: " enclosed",
                                   legendText: "HTMLタイトル",
                                   action: () => hb
                                   .Field(
                                       context: context,
                                       ss: ss,
                                       column: htmlTitleTop,
                                       methodType: tenantModel.MethodType,
                                       value: tenantModel.HtmlTitleTop.ToControl(context: context, ss: ss, column: title),
                                       columnPermissionType: htmlTitleTop.ColumnPermissionType(context: context))
                                   .Field(
                                       context: context,
                                       ss: ss,
                                       column: htmlTitleSite,
                                       methodType: tenantModel.MethodType,
                                       value: tenantModel.HtmlTitleSite.ToControl(context: context, ss: ss, column: title),
                                       columnPermissionType: htmlTitleSite.ColumnPermissionType(context: context))
                                   .Field(
                                       context: context,
                                       ss: ss,
                                       column: htmlTitleRecord,
                                       methodType: tenantModel.MethodType,
                                       value: tenantModel.HtmlTitleRecord.ToControl(context: context, ss: ss, column: title),
                                       columnPermissionType: htmlTitleRecord.ColumnPermissionType(context: context)))));
        }
Пример #12
0
        /// <summary>
        /// Fixed:
        /// </summary>
        private static HtmlBuilder Editor(
            this HtmlBuilder hb, Context context, SiteSettings ss, TenantModel tenantModel)
        {
            var commentsColumn = ss.GetColumn(context: context, columnName: "Comments");
            var commentsColumnPermissionType = commentsColumn
                                               .ColumnPermissionType(context: context);
            var showComments = false;
            var tabsCss      = showComments ? null : "max";

            return(hb.Div(id: "Editor", action: () => hb
                          .Form(
                              attributes: new HtmlAttributes()
                              .Id("TenantForm")
                              .Class("main-form confirm-reload")
                              .Action(Locations.Action(
                                          context: context,
                                          controller: "Tenants",
                                          id: tenantModel.TenantId)),
                              action: () => hb
                              .RecordHeader(
                                  context: context,
                                  ss: ss,
                                  baseModel: tenantModel,
                                  tableName: "Tenants")
                              .Div(
                                  id: "EditorComments", action: () => hb
                                  .Comments(
                                      context: context,
                                      ss: ss,
                                      comments: tenantModel.Comments,
                                      column: commentsColumn,
                                      verType: tenantModel.VerType,
                                      columnPermissionType: commentsColumnPermissionType),
                                  _using: showComments)
                              .Div(id: "EditorTabsContainer", css: tabsCss, action: () => hb
                                   .EditorTabs(
                                       context: context,
                                       tenantModel: tenantModel)
                                   .FieldSetGeneral(context: context, ss: ss, tenantModel: tenantModel)
                                   .FieldSet(
                                       attributes: new HtmlAttributes()
                                       .Id("FieldSetHistories")
                                       .DataAction("Histories")
                                       .DataMethod("post"),
                                       _using: tenantModel.MethodType != BaseModel.MethodTypes.New)
                                   .MainCommands(
                                       context: context,
                                       ss: ss,
                                       siteId: 0,
                                       verType: tenantModel.VerType,
                                       referenceId: tenantModel.TenantId,
                                       updateButton: true,
                                       mailButton: true,
                                       deleteButton: true,
                                       extensions: () => hb
                                       .MainCommandExtensions(
                                           context: context,
                                           tenantModel: tenantModel,
                                           ss: ss)))
                              .Hidden(
                                  controlId: "BaseUrl",
                                  value: Locations.BaseUrl(context: context))
                              .Hidden(
                                  controlId: "MethodType",
                                  value: tenantModel.MethodType.ToString().ToLower())
                              .Hidden(
                                  controlId: "Tenants_Timestamp",
                                  css: "always-send",
                                  value: tenantModel.Timestamp)
                              .Hidden(
                                  controlId: "SwitchTargets",
                                  css: "always-send",
                                  value: tenantModel.SwitchTargets?.Join(),
                                  _using: !context.Ajax))
                          .OutgoingMailsForm(
                              context: context,
                              ss: ss,
                              referenceType: "Tenants",
                              referenceId: tenantModel.TenantId,
                              referenceVer: tenantModel.Ver)
                          .CopyDialog(
                              context: context,
                              referenceType: "Tenants",
                              id: tenantModel.TenantId)
                          .OutgoingMailDialog()
                          .EditorExtensions(
                              context: context,
                              tenantModel: tenantModel,
                              ss: ss)));
        }
Пример #13
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static (byte[] bytes, string contentType) TenantImageLogo(Context context, TenantModel tenantModel)
        {
            var ss      = SiteSettingsUtilities.TenantsSiteSettings(context);
            var invalid = BinaryValidators.OnGetting(
                context: context,
                ss: ss);

            switch (invalid.Type)
            {
            case Error.Types.None: break;

            default: return(null, null);
            }
            var binaryModel = new BinaryModel(
                context: context,
                referenceId: tenantModel.TenantId,
                binaryType: "TenantImage");

            return(
                binaryModel.TenantImage(
                    context: context,
                    sizeType: Libraries.Images.ImageData.SizeTypes.Logo,
                    column: Rds.BinariesColumn().Bin()),
                binaryModel.ContentType.IsNullOrEmpty()
                    ? "image/bmp"
                    : binaryModel.ContentType);
        }
        public static Error.Types OnCreating(
            IContext context, SiteSettings ss, TenantModel tenantModel, bool api = false)
        {
            if (api && (context.ContractSettings.Api == false || !Parameters.Api.Enabled))
            {
                return(Error.Types.InvalidRequest);
            }
            if (!context.CanCreate(ss: ss))
            {
                return(Error.Types.HasNotPermission);
            }
            ss.SetColumnAccessControls(context: context, mine: tenantModel.Mine(context: context));
            foreach (var column in ss.Columns
                     .Where(o => !o.CanCreate)
                     .Where(o => !ss.FormulaTarget(o.ColumnName))
                     .Where(o => !o.Linking))
            {
                switch (column.ColumnName)
                {
                case "TenantName":
                    if (tenantModel.TenantName_Updated(context: context, column: column))
                    {
                        return(Error.Types.HasNotPermission);
                    }
                    break;

                case "Title":
                    if (tenantModel.Title_Updated(context: context, column: column))
                    {
                        return(Error.Types.HasNotPermission);
                    }
                    break;

                case "Body":
                    if (tenantModel.Body_Updated(context: context, column: column))
                    {
                        return(Error.Types.HasNotPermission);
                    }
                    break;

                case "LogoType":
                    if (tenantModel.LogoType_Updated(context: context, column: column))
                    {
                        return(Error.Types.HasNotPermission);
                    }
                    break;

                case "HtmlTitleTop":
                    if (tenantModel.HtmlTitleTop_Updated(context: context, column: column))
                    {
                        return(Error.Types.HasNotPermission);
                    }
                    break;

                case "HtmlTitleSite":
                    if (tenantModel.HtmlTitleSite_Updated(context: context, column: column))
                    {
                        return(Error.Types.HasNotPermission);
                    }
                    break;

                case "HtmlTitleRecord":
                    if (tenantModel.HtmlTitleRecord_Updated(context: context, column: column))
                    {
                        return(Error.Types.HasNotPermission);
                    }
                    break;

                case "ContractDeadline":
                    if (tenantModel.ContractDeadline_Updated(context: context, column: column))
                    {
                        return(Error.Types.HasNotPermission);
                    }
                    break;

                case "Comments":
                    if (!ss.GetColumn(context: context, columnName: "Comments").CanUpdate)
                    {
                        return(Error.Types.HasNotPermission);
                    }
                    break;
                }
            }
            return(Error.Types.None);
        }
Пример #15
0
 /// <summary>
 /// Fixed:
 /// </summary>
 public static HtmlBuilder TenantImageSettingsEditor(this HtmlBuilder hb, Context context, TenantModel tenantModel)
 {
     return(hb.FieldSet(
                id: "TenantImageSettingsEditor",
                css: " enclosed",
                legendText: Displays.LogoImage(context: context),
                action: () => hb
                .FieldTextBox(
                    textType: HtmlTypes.TextTypes.File,
                    controlId: "TenantImage",
                    fieldCss: "field-auto-thin",
                    controlCss: " w400",
                    labelText: Displays.File(context: context))
                .Button(
                    controlId: "SetTenantImage",
                    controlCss: "button-icon",
                    text: Displays.Upload(context: context),
                    onClick: "$p.uploadTenantImage($(this));",
                    icon: "ui-icon-disk",
                    action: "binaries/updatetenantimage",
                    method: "post")
                .Button(
                    controlCss: "button-icon",
                    text: Displays.Delete(context: context),
                    onClick: "$p.send($(this));",
                    icon: "ui-icon-trash",
                    action: "binaries/deletetenantimage",
                    method: "delete",
                    confirm: "ConfirmDelete",
                    _using: BinaryUtilities.ExistsTenantImage(
                        context: context,
                        ss: SiteSettingsUtilities.TenantsSiteSettings(context),
                        referenceId: tenantModel.TenantId,
                        sizeType: Libraries.Images.ImageData.SizeTypes.Logo))));
 }
        public static ErrorData OnCreating(
            Context context, SiteSettings ss, TenantModel tenantModel, bool api = false)
        {
            if (api && (context.ContractSettings.Api == false || !Parameters.Api.Enabled))
            {
                return(new ErrorData(type: Error.Types.InvalidRequest));
            }
            if (!context.CanCreate(ss: ss))
            {
                return(!context.CanRead(ss: ss)
                    ? new ErrorData(type: Error.Types.NotFound)
                    : new ErrorData(type: Error.Types.HasNotPermission));
            }
            ss.SetColumnAccessControls(context: context, mine: tenantModel.Mine(context: context));
            foreach (var column in ss.Columns
                     .Where(o => !o.CanCreate)
                     .Where(o => !ss.FormulaTarget(o.ColumnName))
                     .Where(o => !o.Linking))
            {
                switch (column.ColumnName)
                {
                case "TenantName":
                    if (tenantModel.TenantName_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Title":
                    if (tenantModel.Title_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Body":
                    if (tenantModel.Body_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "DisableAllUsersPermission":
                    if (tenantModel.DisableAllUsersPermission_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "DisableStartGuide":
                    if (tenantModel.DisableStartGuide_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "LogoType":
                    if (tenantModel.LogoType_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "HtmlTitleTop":
                    if (tenantModel.HtmlTitleTop_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "HtmlTitleSite":
                    if (tenantModel.HtmlTitleSite_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "HtmlTitleRecord":
                    if (tenantModel.HtmlTitleRecord_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "ContractDeadline":
                    if (tenantModel.ContractDeadline_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Comments":
                    if (tenantModel.Comments_Updated(context: context))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                default:
                    switch (Def.ExtendedColumnTypes.Get(column.Name))
                    {
                    case "Class":
                        if (tenantModel.Class_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Num":
                        if (tenantModel.Num_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Date":
                        if (tenantModel.Date_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Description":
                        if (tenantModel.Description_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Check":
                        if (tenantModel.Check_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Attachments":
                        if (tenantModel.Attachments_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;
                    }
                    break;
                }
            }
            return(new ErrorData(type: Error.Types.None));
        }
Пример #17
0
        public static HtmlBuilder TdValue(
            this HtmlBuilder hb,
            Context context,
            SiteSettings ss,
            Column column,
            TenantModel tenantModel)
        {
            if (!column.GridDesign.IsNullOrEmpty())
            {
                return(hb.TdCustomValue(
                           context: context,
                           ss: ss,
                           gridDesign: column.GridDesign,
                           tenantModel: tenantModel));
            }
            else
            {
                var mine = tenantModel.Mine(context: context);
                switch (column.Name)
                {
                case "Ver":
                    return(ss.ReadColumnAccessControls.Allowed(
                               context: context,
                               ss: ss,
                               column: column,
                               type: ss.PermissionType,
                               mine: mine)
                                ? hb.Td(
                               context: context,
                               column: column,
                               value: tenantModel.Ver)
                                : hb.Td(
                               context: context,
                               column: column,
                               value: string.Empty));

                case "Comments":
                    return(ss.ReadColumnAccessControls.Allowed(
                               context: context,
                               ss: ss,
                               column: column,
                               type: ss.PermissionType,
                               mine: mine)
                                ? hb.Td(
                               context: context,
                               column: column,
                               value: tenantModel.Comments)
                                : hb.Td(
                               context: context,
                               column: column,
                               value: string.Empty));

                case "Creator":
                    return(ss.ReadColumnAccessControls.Allowed(
                               context: context,
                               ss: ss,
                               column: column,
                               type: ss.PermissionType,
                               mine: mine)
                                ? hb.Td(
                               context: context,
                               column: column,
                               value: tenantModel.Creator)
                                : hb.Td(
                               context: context,
                               column: column,
                               value: string.Empty));

                case "Updator":
                    return(ss.ReadColumnAccessControls.Allowed(
                               context: context,
                               ss: ss,
                               column: column,
                               type: ss.PermissionType,
                               mine: mine)
                                ? hb.Td(
                               context: context,
                               column: column,
                               value: tenantModel.Updator)
                                : hb.Td(
                               context: context,
                               column: column,
                               value: string.Empty));

                case "CreatedTime":
                    return(ss.ReadColumnAccessControls.Allowed(
                               context: context,
                               ss: ss,
                               column: column,
                               type: ss.PermissionType,
                               mine: mine)
                                ? hb.Td(
                               context: context,
                               column: column,
                               value: tenantModel.CreatedTime)
                                : hb.Td(
                               context: context,
                               column: column,
                               value: string.Empty));

                case "UpdatedTime":
                    return(ss.ReadColumnAccessControls.Allowed(
                               context: context,
                               ss: ss,
                               column: column,
                               type: ss.PermissionType,
                               mine: mine)
                                ? hb.Td(
                               context: context,
                               column: column,
                               value: tenantModel.UpdatedTime)
                                : hb.Td(
                               context: context,
                               column: column,
                               value: string.Empty));

                default: return(hb);
                }
            }
        }