示例#1
0
        /// <summary>
        /// Try to Import from selected File
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Import_OnClick([NotNull] object sender, [NotNull] EventArgs e)
        {
            // import selected file (if it's the proper format)...
            if (!this.importFile.PostedFile.ContentType.StartsWith("text"))
            {
                this.PageContext.AddLoadMessage(
                    this.GetText("ADMIN_BANNEDIP_IMPORT", "IMPORT_FAILED")
                    .FormatWith(this.importFile.PostedFile.ContentType));

                return;
            }

            try
            {
                var importedCount = DataImport.BannedIpAdressesImport(
                    this.PageContext.PageBoardID,
                    this.PageContext.PageUserID,
                    this.importFile.PostedFile.InputStream);

                this.PageContext.AddLoadMessage(
                    importedCount > 0
                        ? this.GetText("ADMIN_BANNEDIP_IMPORT", "IMPORT_SUCESS").FormatWith(importedCount)
                        : this.GetText("ADMIN_BANNEDIP_IMPORT", "IMPORT_NOTHING"),
                    MessageTypes.success);
            }
            catch (Exception x)
            {
                this.PageContext.AddLoadMessage(
                    this.GetText("ADMIN_BANNEDIP_IMPORT", "IMPORT_FAILED").FormatWith(x.Message), MessageTypes.danger);
            }
        }
示例#2
0
        /// <summary>
        /// Try to Import from selected File
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Import_OnClick([NotNull] object sender, [NotNull] EventArgs e)
        {
            // import selected file (if it's the proper format)...
            if (!this.importFile.PostedFile.ContentType.StartsWith(value: "text"))
            {
                this.PageContext.AddLoadMessage(
                    message: string
                    .Format(format: this.GetText(page: "ADMIN_BANNEDIP_IMPORT", tag: "IMPORT_FAILED"), arg0: this.importFile.PostedFile.ContentType));

                return;
            }

            try
            {
                var importedCount = DataImport.BannedIpAdressesImport(
                    boardId: this.PageContext.PageBoardID,
                    userId: this.PageContext.PageUserID,
                    inputStream: this.importFile.PostedFile.InputStream);

                this.PageContext.AddLoadMessage(
                    message: importedCount > 0
                        ? string.Format(format: this.GetText(page: "ADMIN_BANNEDIP_IMPORT", tag: "IMPORT_SUCESS"), arg0: importedCount)
                        : this.GetText(page: "ADMIN_BANNEDIP_IMPORT", tag: "IMPORT_NOTHING"),
                    messageType: MessageTypes.success);
            }
            catch (Exception x)
            {
                this.PageContext.AddLoadMessage(
                    message: string.Format(format: this.GetText(page: "ADMIN_BANNEDIP_IMPORT", tag: "IMPORT_FAILED"), arg0: x.Message), messageType: MessageTypes.danger);
            }
        }