Exemple #1
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))));
 }
        /// <summary>
        /// Fixed:
        /// </summary>
        public static Error.Types OnUploading(
            Column column,
            Libraries.DataTypes.Attachments attachments,
            System.Web.HttpPostedFileBase[] files)
        {
            if (!Contract.Attachments())
            {
                return(Error.Types.BadRequest);
            }
            if (OverLimitQuantity(attachments.Count(), files.Count(), column.LimitQuantity))
            {
                return(Error.Types.OverLimitQuantity);
            }
            if (OverLimitSize(files, column.LimitSize))
            {
                return(Error.Types.OverLimitSize);
            }
            var newTotalFileSize = files.Sum(x => x.ContentLength);

            if (OverTotalLimitSize(
                    attachments.Select(x => x.Size.ToLong()).Sum(),
                    newTotalFileSize,
                    column.TotalLimitSize))
            {
                return(Error.Types.OverTotalLimitSize);
            }
            if (OverTenantTotalLimitSize(
                    BinaryUtilities.TenantBinSize(),
                    newTotalFileSize,
                    Contract.TenantAttachmentsSize()))
            {
                return(Error.Types.OverTenantTotalLimitSize);
            }
            return(Error.Types.None);
        }
Exemple #3
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static Error.Types OnUploading(
            Column column,
            Libraries.DataTypes.Attachments attachments,
            ICollection <IFormFile> files)
        {
            if (!Contract.Attachments())
            {
                return(Error.Types.BadRequest);
            }
            if (OverLimitQuantity(attachments.Count(), files.Count(), column.LimitQuantity))
            {
                return(Error.Types.OverLimitQuantity);
            }
            if (OverLimitSize(files, column.LimitSize))
            {
                return(Error.Types.OverLimitSize);
            }
            var newTotalFileSize = files.Sum(x => x.Length);

            if (OverTotalLimitSize(
                    attachments.Select(x => x.Size.ToLong()).Sum(),
                    newTotalFileSize,
                    column.TotalLimitSize))
            {
                return(Error.Types.OverTotalLimitSize);
            }
            if (OverTenantStorageSize(
                    BinaryUtilities.UsedTenantStorageSize(),
                    newTotalFileSize,
                    Contract.TenantStorageSize()))
            {
                return(Error.Types.OverTenantStorageSize);
            }
            return(Error.Types.None);
        }
Exemple #4
0
        public Error.Types Create(
            SiteSettings ss,
            RdsUser rdsUser           = null,
            Sqls.TableTypes tableType = Sqls.TableTypes.Normal,
            SqlParamCollection param  = null,
            bool extendedSqls         = true,
            bool notice         = false,
            bool otherInitValue = false,
            bool get            = true)
        {
            var statements = new List <SqlStatement>();

            if (extendedSqls)
            {
                statements.OnCreatingExtendedSqls(SiteId);
            }
            CreateStatements(ss, statements, tableType, param, otherInitValue);
            var response = Rds.ExecuteScalar_response(
                rdsUser: rdsUser,
                transactional: true,
                selectIdentity: true,
                statements: statements.ToArray());

            WikiId = (response.Identity ?? WikiId).ToLong();
            if (Contract.Notice() && notice)
            {
                SetTitle(ss);
                CheckNotificationConditions(ss);
                Notice(ss, "Created");
            }
            if (get)
            {
                Get(ss);
            }
            var fullText = FullText(ss, onCreating: true);

            statements = new List <SqlStatement>();
            statements.Add(Rds.UpdateItems(
                               param: Rds.ItemsParam()
                               .Title(Title.DisplayValue)
                               .FullText(fullText, _using: fullText != null)
                               .SearchIndexCreatedTime(DateTime.Now, _using: fullText != null),
                               where : Rds.ItemsWhere().ReferenceId(WikiId)));
            statements.Add(BinaryUtilities.UpdateReferenceId(ss, WikiId, fullText));
            if (extendedSqls)
            {
                statements.OnCreatedExtendedSqls(SiteId, WikiId);
            }
            Rds.ExecuteNonQuery(
                rdsUser: rdsUser,
                transactional: true,
                statements: statements.ToArray());
            Libraries.Search.Indexes.Create(ss, this);
            if (get && Rds.ExtendedSqls(SiteId, WikiId)?.Any(o => o.OnCreated) == true)
            {
                Get(ss);
            }
            return(Error.Types.None);
        }
Exemple #5
0
 /// <summary>
 /// Fixed:
 /// </summary>
 public static Error.Types OnUploading(
     Context context,
     SiteSettings ss,
     Dictionary <string, Libraries.DataTypes.Attachments> attachmentsHash)
 {
     if (!context.ContractSettings.Attachments())
     {
         return(Error.Types.BadRequest);
     }
     foreach (var keyValue in attachmentsHash)
     {
         var column = ss.GetColumn(
             context: context,
             columnName: keyValue.Key);
         var attachments = keyValue.Value;
         if (OverLimitQuantity(
                 attachments: attachments,
                 limitQuantity: column.LimitQuantity))
         {
             return(Error.Types.OverLimitQuantity);
         }
         if (OverLimitSize(
                 attachments: attachments,
                 limitSize: column.LimitSize))
         {
             return(Error.Types.OverLimitSize);
         }
         if (OverTotalLimitSize(
                 attachments: attachments,
                 totalLimitSize: column.TotalLimitSize))
         {
             return(Error.Types.OverTotalLimitSize);
         }
         if (OverTenantStorageSize(
                 totalFileSize: BinaryUtilities.UsedTenantStorageSize(context: context),
                 newTotalFileSize: attachmentsHash
                 .Select(o =>
                         o.Value.Where(p => p.Added == true).Select(p => p.Size).Sum()
                         - o.Value.Where(p => p.Deleted == true).Select(p => p.Size).Sum())
                 .Sum()
                 .ToDecimal(),
                 storageSize: context.ContractSettings.StorageSize))
         {
             return(Error.Types.OverTenantStorageSize);
         }
     }
     return(Error.Types.None);
 }
Exemple #6
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static Error.Types OnUploadingImage(Context context)
        {
            if (!context.ContractSettings.Attachments())
            {
                return(Error.Types.BadRequest);
            }
            var newTotalFileSize = context.PostedFiles.Sum(x => x.Size);

            if (OverTenantStorageSize(
                    BinaryUtilities.UsedTenantStorageSize(context: context),
                    newTotalFileSize,
                    context.ContractSettings.StorageSize))
            {
                return(Error.Types.OverTenantStorageSize);
            }
            return(Error.Types.None);
        }
Exemple #7
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static Error.Types OnUploadingImage(ICollection <IFormFile> files)
        {
            if (!Contract.Attachments())
            {
                return(Error.Types.BadRequest);
            }
            var newTotalFileSize = files.Sum(x => x.Length);

            if (OverTenantStorageSize(
                    BinaryUtilities.UsedTenantStorageSize(),
                    newTotalFileSize,
                    Contract.TenantStorageSize()))
            {
                return(Error.Types.OverTenantStorageSize);
            }
            return(Error.Types.None);
        }
        /// <summary>
        /// Fixed:
        /// </summary>
        public static Error.Types OnUploadingImage(System.Web.HttpPostedFileBase[] files)
        {
            if (!Contract.Attachments())
            {
                return(Error.Types.BadRequest);
            }
            var newTotalFileSize = files.Sum(x => x.ContentLength);

            if (OverTenantStorageSize(
                    BinaryUtilities.UsedTenantStorageSize(),
                    newTotalFileSize,
                    Contract.TenantStorageSize()))
            {
                return(Error.Types.OverTenantStorageSize);
            }
            return(Error.Types.None);
        }
Exemple #9
0
 /// <summary>
 /// Fixed:
 /// </summary>
 public static Error.Types OnUploading(
     Context context,
     Column column,
     Libraries.DataTypes.Attachments attachments)
 {
     if (!context.ContractSettings.Attachments())
     {
         return(Error.Types.BadRequest);
     }
     if (OverLimitQuantity(
             attachments: attachments,
             limitQuantity: column.LimitQuantity))
     {
         return(Error.Types.OverLimitQuantity);
     }
     if (OverLimitSize(
             attachments: attachments,
             limitSize: column.LimitSize))
     {
         return(Error.Types.OverLimitSize);
     }
     if (OverTotalLimitSize(
             attachments: attachments,
             totalLimitSize: column.TotalLimitSize))
     {
         return(Error.Types.OverTotalLimitSize);
     }
     if (OverTenantStorageSize(
             totalFileSize: BinaryUtilities.UsedTenantStorageSize(context: context),
             newTotalFileSize: attachments
             .Select(o => o.Added == true
                 ? o.Size
                 : o.Deleted == true
                     ? o.Size * -1
                     : 0)
             .Sum()
             .ToDecimal(),
             storageSize: context.ContractSettings.StorageSize))
     {
         return(Error.Types.OverTenantStorageSize);
     }
     return(Error.Types.None);
 }
Exemple #10
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static Error.Types OnUploading(
            Context context,
            Column column,
            Libraries.DataTypes.Attachments attachments)
        {
            if (!context.ContractSettings.Attachments())
            {
                return(Error.Types.BadRequest);
            }
            if (OverLimitQuantity(
                    attachments?.Count().ToDecimal() ?? 0,
                    context.PostedFiles?.Count().ToDecimal() ?? 0,
                    column.LimitQuantity))
            {
                return(Error.Types.OverLimitQuantity);
            }
            if (OverLimitSize(context, column.LimitSize))
            {
                return(Error.Types.OverLimitSize);
            }
            var newTotalFileSize = context.PostedFiles.Sum(x => x.Size.ToDecimal());

            if (OverTotalLimitSize(
                    attachments?.Select(x => x.Size.ToDecimal()).Sum() ?? 0,
                    newTotalFileSize,
                    column.TotalLimitSize))
            {
                return(Error.Types.OverTotalLimitSize);
            }
            if (OverTenantStorageSize(
                    BinaryUtilities.UsedTenantStorageSize(context: context),
                    newTotalFileSize,
                    context.ContractSettings.StorageSize))
            {
                return(Error.Types.OverTenantStorageSize);
            }
            return(Error.Types.None);
        }
Exemple #11
0
 /// <summary>
 /// Fixed:
 /// </summary>
 private static Error.Types OverLimitSize(
     Libraries.DataTypes.Attachments attachments, Column column)
 {
     foreach (var attachment in attachments
              .Where(o => o.Added == true && o.Deleted != true))
     {
         if (BinaryUtilities.BinaryStorageProvider(column, attachment.Size ?? 0) == "LocalFolder")
         {
             if (attachment.Size > column.LocalFolderLimitSize * 1024 * 1024)
             {
                 return(Error.Types.OverLocalFolderLimitSize);
             }
         }
         else
         {
             if (attachment.Size > column.LimitSize * 1024 * 1024)
             {
                 return(Error.Types.OverLimitSize);
             }
         }
     }
     return(Error.Types.None);
 }
Exemple #12
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static Error.Types OnUploading(
            Context context,
            Column column,
            Libraries.DataTypes.Attachments attachments,
            IList <PostedFile> files,
            System.Collections.Generic.IEnumerable <System.Net.Http.Headers.ContentRangeHeaderValue> contentRanges)
        {
            if (!context.ContractSettings.Attachments())
            {
                return(Error.Types.BadRequest);
            }
            if (files.Count != contentRanges.Count())
            {
                return(Error.Types.BadRequest);
            }
            if (OverLimitQuantity(
                    attachments: attachments,
                    limitQuantity: column.LimitQuantity,
                    newFileCount: files.Count()))
            {
                return(Error.Types.OverLimitQuantity);
            }
            var totalLength = default(long);

            foreach (var length in contentRanges.Select(r => r.Length ?? default(long)))
            {
                if (BinaryUtilities.BinaryStorageProvider(column, length) == "LocalFolder")
                {
                    if (OverLimitSize(
                            length: length,
                            limitSize: column.LocalFolderLimitSize))
                    {
                        return(Error.Types.OverLocalFolderLimitSize);
                    }
                }
                else
                {
                    if (OverLimitSize(
                            length: length,
                            limitSize: column.LimitSize))
                    {
                        return(Error.Types.OverLimitSize);
                    }
                }
                totalLength += length;
            }
            switch (BinaryUtilities.BinaryStorageProvider(column))
            {
            case "LocalFolder":
                if (OverTotalLimitSize(
                        attachments: attachments,
                        totalLimitSize: column.LocalFolderTotalLimitSize,
                        newFileTotalSize: totalLength))
                {
                    return(Error.Types.OverLocalFolderTotalLimitSize);
                }
                break;

            case "AutoDataBaseOrLocalFolder":
                if (OverTotalLimitSize(
                        attachments: attachments,
                        totalLimitSize: column.TotalLimitSize,
                        newFileTotalSize: totalLength))
                {
                    return(Error.Types.OverTotalLimitSize);
                }
                break;

            default:
                if (OverTotalLimitSize(
                        attachments: attachments,
                        totalLimitSize: column.TotalLimitSize,
                        newFileTotalSize: totalLength))
                {
                    return(Error.Types.OverTotalLimitSize);
                }
                break;
            }
            if (OverTenantStorageSize(
                    BinaryUtilities.UsedTenantStorageSize(context),
                    totalLength,
                    context.ContractSettings.StorageSize))
            {
                return(Error.Types.OverTenantStorageSize);
            }
            return(Error.Types.None);
        }
Exemple #13
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static Error.Types OnUploading(
            Context context,
            Column column,
            Libraries.DataTypes.Attachments attachments)
        {
            if (!context.ContractSettings.Attachments())
            {
                return(Error.Types.BadRequest);
            }
            if (OverLimitQuantity(
                    attachments: attachments,
                    limitQuantity: column.LimitQuantity))
            {
                return(Error.Types.OverLimitQuantity);
            }
            var errorType = OverLimitSize(
                attachments: attachments,
                column: column);

            if (errorType != Error.Types.None)
            {
                return(errorType);
            }
            switch (BinaryUtilities.BinaryStorageProvider(column))
            {
            case "LocalFolder":
                if (OverTotalLimitSize(
                        attachments: attachments,
                        totalLimitSize: column.LocalFolderTotalLimitSize))
                {
                    return(Error.Types.OverLocalFolderTotalLimitSize);
                }
                break;

            case "AutoDataBaseOrLocalFolder":
                if (OverTotalLimitSize(
                        attachments: attachments,
                        totalLimitSize: column.TotalLimitSize))
                {
                    return(Error.Types.OverTotalLimitSize);
                }
                break;

            default:
                if (OverTotalLimitSize(
                        attachments: attachments,
                        totalLimitSize: column.TotalLimitSize))
                {
                    return(Error.Types.OverTotalLimitSize);
                }
                break;
            }
            if (OverTenantStorageSize(
                    totalFileSize: BinaryUtilities.UsedTenantStorageSize(context: context),
                    newTotalFileSize: attachments
                    .Select(o => o.Added == true
                        ? o.Size
                        : o.Deleted == true
                            ? o.Size * -1
                            : 0)
                    .Sum()
                    .ToDecimal(),
                    storageSize: context.ContractSettings.StorageSize))
            {
                return(Error.Types.OverTenantStorageSize);
            }
            return(Error.Types.None);
        }