コード例 #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_BANNEDNAME_IMPORT", "IMPORT_FAILED")
                    .FormatWith(this.importFile.PostedFile.ContentType));

                return;
            }

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

                this.PageContext.LoadMessage.AddSession(
                    importedCount > 0
                        ? this.GetText("ADMIN_BANNEDNAME_IMPORT", "IMPORT_SUCESS").FormatWith(importedCount)
                        : this.GetText("ADMIN_BANNEDNAME_IMPORT", "IMPORT_NOTHING"),
                    MessageTypes.Information);

                YafBuildLink.Redirect(ForumPages.admin_bannedname);
            }
            catch (Exception x)
            {
                this.PageContext.AddLoadMessage(
                    this.GetText("ADMIN_BANNEDNAME_IMPORT", "IMPORT_FAILED").FormatWith(x.Message));
            }
        }
コード例 #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("text"))
            {
                this.PageContext.AddLoadMessage(
                    this.GetTextFormatted("IMPORT_FAILED", this.importFile.PostedFile.ContentType),
                    MessageTypes.danger);

                return;
            }

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

                this.PageContext.AddLoadMessage(
                    importedCount > 0
                        ? this.GetTextFormatted("IMPORT_SUCESS", importedCount)
                        : this.GetText("ADMIN_BANNEDNAME_IMPORT", "IMPORT_NOTHING"),
                    MessageTypes.success);
            }
            catch (Exception x)
            {
                this.PageContext.AddLoadMessage(
                    string.Format(this.GetText("ADMIN_BANNEDNAME_IMPORT", "IMPORT_FAILED"), x.Message), MessageTypes.danger);
            }
        }
コード例 #3
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_BANNEDNAME_IMPORT", tag: "IMPORT_FAILED"), arg0: this.importFile.PostedFile.ContentType));

                return;
            }

            try
            {
                var importedCount = DataImport.BannedNamesImport(
                    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_BANNEDNAME_IMPORT", tag: "IMPORT_SUCESS"), arg0: importedCount)
                        : this.GetText(page: "ADMIN_BANNEDNAME_IMPORT", tag: "IMPORT_NOTHING"),
                    messageType: MessageTypes.success);
            }
            catch (Exception x)
            {
                this.PageContext.AddLoadMessage(
                    message: string.Format(format: this.GetText(page: "ADMIN_BANNEDNAME_IMPORT", tag: "IMPORT_FAILED"), arg0: x.Message), messageType: MessageTypes.danger);
            }
        }