<commit_before>/**
 * @license
 * Copyright color-coding studio. All Rights Reserved.
 *
 * Use of this source code is governed by an Apache License, Version 2.0
 * that can be found in the LICENSE file at http://www.apache.org/licenses/LICENSE-2.0
 */

import * as ibas from "ibas/index";
import * as bo from "../../borep/bo/index";
import { BORepositoryInitialFantasy } from "../../borep/BORepositories";

/** 应用-更改用户配置 */
export class ChangeUserProfileApp extends ibas.Application<IChangeUserProfileView> implements ibas.IService<ibas.IServiceCaller<ibas.IServiceContract>> {

    /** 应用标识 */
    static APPLICATION_ID: string = "2868c3e7-52e3-409d-acba-a62ad0a668bb";
    /** 应用名称 */
    static APPLICATION_NAME: string = "initialfantasy_app_change_user_profile";

    constructor() {
        super();
        this.id = ChangeUserProfileApp.APPLICATION_ID;
        this.name = ChangeUserProfileApp.APPLICATION_NAME;
        this.description = ibas.i18n.prop(this.name);
    }
    /** 注册视图 */
    protected registerView(): void {
        super.registerView();
        // 其他事件
        this.view.saveUserEvent = this.saveUser;
    }
    /** 视图显示后 */
    protected viewShowed(): void {
        // 视图加载完成
    }
    /** 运行 */
    run(): void;
    /**
     * 运行
     * @param caller 服务调用者
     */
    run(caller: ibas.IServiceCaller<ibas.IServiceContract>): void;
    /** 运行 */
    run(): void {
        super.run.apply(this, arguments);
        if (arguments.length === 1) {
            let caller: ibas.IServiceCaller<ibas.IServiceContract> = arguments[0];
            let criteria: ibas.ICriteria = new ibas.Criteria();
            let condition: ibas.ICondition = criteria.conditions.create();
            condition.alias = bo.User.PROPERTY_CODE_NAME;
            if (!ibas.strings.isEmpty(caller.category)) {
                condition.value = caller.category.substring(caller.category.lastIndexOf("/") + 1);
            }
            if (ibas.objects.isNull(condition.value)) {
                condition.value = ibas.variablesManager.getValue(ibas.VARIABLE_NAME_USER_CODE);
            }
            this.fetchUser(criteria);
        }
    }
    private user: bo.User;
    private fetchUser(criteria: ibas.ICriteria): void {
        let that: this = this;
        let boRepository: BORepositoryInitialFantasy = new BORepositoryInitialFantasy();
        boRepository.fetchUser({
            criteria: criteria,
            onCompleted(opRslt: ibas.IOperationResult<bo.User>): void {
                that.user = opRslt.resultObjects.firstOrDefault();
                if (ibas.objects.isNull(that.user)) {
                    that.user = new bo.User();
                    that.user.code = "UNKNOWN";
                    that.user.name = ibas.i18n.prop("shell_unknown_user");
                }
                that.view.showUser(that.user);
            }
        });<commit_msg>操作成功清理哈希值<commit_after>/**
 * @license
 * Copyright color-coding studio. All Rights Reserved.
 *
 * Use of this source code is governed by an Apache License, Version 2.0
 * that can be found in the LICENSE file at http://www.apache.org/licenses/LICENSE-2.0
 */

import * as ibas from "ibas/index";
import * as bo from "../../borep/bo/index";
import { BORepositoryInitialFantasy } from "../../borep/BORepositories";

/** 应用-更改用户配置 */
export class ChangeUserProfileApp extends ibas.Application<IChangeUserProfileView> implements ibas.IService<ibas.IServiceCaller<ibas.IServiceContract>> {

    /** 应用标识 */
    static APPLICATION_ID: string = "2868c3e7-52e3-409d-acba-a62ad0a668bb";
    /** 应用名称 */
    static APPLICATION_NAME: string = "initialfantasy_app_change_user_profile";

    constructor() {
        super();
        this.id = ChangeUserProfileApp.APPLICATION_ID;
        this.name = ChangeUserProfileApp.APPLICATION_NAME;
        this.description = ibas.i18n.prop(this.name);
    }
    /** 注册视图 */
    protected registerView(): void {
        super.registerView();
        // 其他事件
        this.view.saveUserEvent = this.saveUser;
    }
    /** 视图显示后 */
    protected viewShowed(): void {
        // 视图加载完成
    }
    /** 运行 */
    run(): void;
    /**
     * 运行
     * @param caller 服务调用者
     */
    run(caller: ibas.IServiceCaller<ibas.IServiceContract>): void;
    /** 运行 */
    run(): void {
        super.run.apply(this, arguments);
        if (arguments.length === 1) {
            let caller: ibas.IServiceCaller<ibas.IServiceContract> = arguments[0];
            let criteria: ibas.ICriteria = new ibas.Criteria();
            let condition: ibas.ICondition = criteria.conditions.create();
            condition.alias = bo.User.PROPERTY_CODE_NAME;
            if (!ibas.strings.isEmpty(caller.category)) {
                condition.value = caller.category.substring(caller.category.lastIndexOf("/") + 1);
                ibas.hashEventManager.changeHash("#");
            }
            if (ibas.objects.isNull(condition.value)) {
                condition.value = ibas.variablesManager.getValue(ibas.VARIABLE_NAME_USER_CODE);
            }
            this.fetchUser(criteria);
        }
    }
    private user: bo.User;
    private fetchUser(criteria: ibas.ICriteria): void {
        let that: this = this;
        let boRepository: BORepositoryInitialFantasy = new BORepositoryInitialFantasy();
        boRepository.fetchUser({
            criteria: criteria,
            onCompleted(opRslt: ibas.IOperationResult<bo.User>): void {
                that.user = opRslt.resultObjects.firstOrDefault();
                if (ibas.objects.isNull(that.user)) {
                    that.user = new bo.User();
                    that.user.code = "UNKNOWN";
                    that.user.name = ibas.i18n.prop("shell_unknown_user");
                }
                that.view.showUser(that.user);
            }
        });
{'fraction_non_alphanumeric': 0.12472006890611542, 'fraction_numerical': 0.009991386735572783, 'mean_word_length': 2.2435754189944133, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1697423', 'n_tokens_mistral': 1853, 'n_tokens_neox': 1838, 'n_words': 323}