Esempio n. 1
0
    public string GetLoginUserInfo(string token)
    {
        this.log(LogLevel.DEBUG, FunctionName.WS_GET_LOGIN_USER_INFO, MessageType.PARAMATER, string.Format("token:{0}", token));

        //验证参数
        bool ret = ArgumentHelper.Validate("token", token, false);

        if (!ret)
        {
            this.log(LogLevel.ERROR, FunctionName.WS_GET_LOGIN_USER_INFO, "token", "参数不正确");
            this.log(LogLevel.INFO, FunctionName.WS_GET_LOGIN_USER_INFO, MessageType.RESULT, "");
            return("");
        }

        //取token的登录用户ID
        string cu_id = this.GetCustomerService().GetLoginCustomerUserIDByToken(token);

        if (string.IsNullOrEmpty(cu_id))
        {
            this.log(LogLevel.ERROR, FunctionName.WS_GET_LOGIN_USER_INFO, "CustomerUserID", "未找到");
            this.log(LogLevel.INFO, FunctionName.WS_GET_LOGIN_USER_INFO, MessageType.RESULT, "");
            return("");
        }
        this.log(LogLevel.DEBUG, FunctionName.WS_GET_LOGIN_USER_INFO, "CustomerUserID", cu_id);

        //取登录用户
        CustomerUserInfo cUser = this.GetCustomerService().GetCustomerUserByID(cu_id);

        if (cUser == null)
        {
            this.log(LogLevel.ERROR, FunctionName.WS_GET_LOGIN_USER_INFO, "CustomerUser", "未找到");
            this.log(LogLevel.INFO, FunctionName.WS_GET_LOGIN_USER_INFO, MessageType.RESULT, "");
            return("");
        }

        LoggingUserInfo user = new LoggingUserInfo();

        user.CustomerID   = cUser.Customer.ID;
        user.CustomerCode = cUser.Customer.Code;
        user.CustomerName = cUser.Customer.Name;
        user.UserID       = cUser.ID;
        user.UserName     = cUser.Name;
        CustomerConnectInfo cConnect = this.GetCustomerService().GetCustomerConnectByID(cUser.Customer.ID);

        if (cConnect != null)
        {
            user.ConnectionString = cConnect.DBConnectionString;
        }
        string s = XMLGenerator.Serialize(user);

        this.log(LogLevel.DEBUG, FunctionName.WS_GET_LOGIN_USER_INFO, "DecryptResult", s);

        //加密
        cPos.Admin.Service.BaseService base_service = this.GetCustomerService() as cPos.Admin.Service.BaseService;
        string output = base_service.EncryptStringByKeyFile(cConnect.KeyFile, s);

        this.log(LogLevel.DEBUG, FunctionName.WS_GET_LOGIN_USER_INFO, MessageType.RESULT, output);

        return(output);
    }
    public bool SynTerminal(string customerID, int typeID, string terminalInfo)
    {
        this.log(LogLevel.DEBUG, FunctionName.WS_SYS_TERMINAL, MessageType.PARAMATER, "customerID: " + customerID);
        this.log(LogLevel.DEBUG, FunctionName.WS_SYS_TERMINAL, MessageType.PARAMATER, "typeID: " + typeID.ToString());
        this.log(LogLevel.DEBUG, FunctionName.WS_SYS_TERMINAL, MessageType.PARAMATER, "terminalInfo: " + terminalInfo);

        //验证参数
        bool ret = ArgumentHelper.Validate("customerID", customerID, false);

        if (!ret)
        {
            this.log(LogLevel.ERROR, FunctionName.WS_SYS_TERMINAL, "customerID", "参数不正确");
            this.log(LogLevel.INFO, FunctionName.WS_SYS_TERMINAL, MessageType.RESULT, ret.ToString());
            return(ret);
        }

        CustomerConnectInfo cConnect = this.GetCustomerService().GetCustomerConnectByID(customerID);

        if (cConnect == null)
        {
            this.log(LogLevel.ERROR, FunctionName.WS_SYS_TERMINAL, "CustomerConnect", "未找到");
            this.log(LogLevel.INFO, FunctionName.WS_SYS_TERMINAL, MessageType.RESULT, "false");
            return(false);
        }

        if (typeID < 1 || typeID > 2)
        {
            this.log(LogLevel.ERROR, FunctionName.WS_SYS_TERMINAL, "typeID", "参数不正确");
            this.log(LogLevel.INFO, FunctionName.WS_SYS_TERMINAL, MessageType.RESULT, "false");
            return(false);
        }

        //解密
        cPos.Admin.Service.BaseService base_service = this.GetCustomerService() as cPos.Admin.Service.BaseService;
        string s = base_service.DecryptStringByCustomer(customerID, terminalInfo);

        this.log(LogLevel.DEBUG, FunctionName.WS_SYS_TERMINAL, "DecryptCustomerTerminal", s);

        CustomerTerminalInfo terminal = (CustomerTerminalInfo)XMLGenerator.Deserialize(typeof(CustomerTerminalInfo), s);

        terminal.Customer.ID = customerID;
        switch (typeID)
        {
        case 1:    //新建
            ret = this.GetCustomerService().InsertCustomerTerminalFromCP(terminal);
            break;

        case 2:    //修改
            ret = this.GetCustomerService().ModifyCustomerTerminalFromCP(terminal);
            break;

        default:
            ret = false;
            break;
        }
        this.log(LogLevel.INFO, FunctionName.WS_SYS_TERMINAL, MessageType.RESULT, ret.ToString());
        return(ret);
    }
Esempio n. 3
0
    public string GetCustomerDBConnectionString(string customerID)
    {
        this.log(LogLevel.DEBUG, FunctionName.WS_GET_CUSTOMER_DB_CONNECTION_STRING,
                 MessageType.PARAMATER, string.Format("customerID:{0}", customerID));

        //验证参数
        bool ret = ArgumentHelper.Validate("customerID", customerID, false);

        if (!ret)
        {
            this.log(LogLevel.ERROR, FunctionName.WS_GET_LOGIN_USER_INFO, "customerID", "参数不正确");
            this.log(LogLevel.INFO, FunctionName.WS_GET_LOGIN_USER_INFO, MessageType.RESULT, "");
            return("");
        }

        //取连接
        CustomerConnectInfo cConnect = this.GetCustomerService().GetCustomerConnectByID(customerID);

        if (cConnect == null)
        {
            this.log(LogLevel.ERROR, FunctionName.WS_GET_LOGIN_USER_INFO, "CustomerConnect", "未找到");
            this.log(LogLevel.INFO, FunctionName.WS_GET_LOGIN_USER_INFO, MessageType.RESULT, "");
            return("");
        }

        //生成XML
        LoggingUserInfo user = new LoggingUserInfo();

        user.CustomerID       = customerID;
        user.CustomerCode     = cConnect.Customer.Code;
        user.CustomerName     = cConnect.Customer.Name;
        user.ConnectionString = cConnect.DBConnectionString;
        string s = XMLGenerator.Serialize(user);

        this.log(LogLevel.DEBUG, FunctionName.WS_GET_LOGIN_USER_INFO, "DecryptResult", s);

        //加密
        cPos.Admin.Service.BaseService base_service = this.GetCustomerService() as cPos.Admin.Service.BaseService;
        string output = base_service.EncryptStringByKeyFile(cConnect.KeyFile, s);

        this.log(LogLevel.DEBUG, FunctionName.WS_GET_LOGIN_USER_INFO, MessageType.RESULT, output);

        return(output);
    }
    public bool SynUser(string customerID, int typeID, string userInfo)
    {
        this.log(LogLevel.DEBUG, FunctionName.WS_SYN_USER, MessageType.PARAMATER, "customerID: " + customerID);
        this.log(LogLevel.DEBUG, FunctionName.WS_SYN_USER, MessageType.PARAMATER, "typeID: " + typeID.ToString());
        this.log(LogLevel.DEBUG, FunctionName.WS_SYN_USER, MessageType.PARAMATER, "userInfo: " + userInfo);

        //验证参数
        bool ret = ArgumentHelper.Validate("customerID", customerID, false);

        if (!ret)
        {
            this.log(LogLevel.ERROR, FunctionName.WS_SYN_USER, "customerID", "参数不正确");
            this.log(LogLevel.INFO, FunctionName.WS_SYN_USER, MessageType.RESULT, ret.ToString());
            return(ret);
        }

        //获取连接
        CustomerConnectInfo cConnect = this.GetCustomerService().GetCustomerConnectByID(customerID);

        if (cConnect == null)
        {
            this.log(LogLevel.ERROR, FunctionName.WS_SYN_USER, "CustomerConnect", "未找到");
            this.log(LogLevel.INFO, FunctionName.WS_SYN_USER, MessageType.RESULT, "false");
            return(false);
        }

        if (typeID < 1 || typeID > 5)
        {
            this.log(LogLevel.ERROR, FunctionName.WS_SYN_USER, "typeID", "参数不正确");
            this.log(LogLevel.INFO, FunctionName.WS_SYN_USER, MessageType.RESULT, "false");
            return(false);
        }

        //解密
        cPos.Admin.Service.BaseService base_service = this.GetCustomerService() as cPos.Admin.Service.BaseService;
        string s = base_service.DecryptStringByCustomer(customerID, userInfo);

        this.log(LogLevel.DEBUG, FunctionName.WS_SYN_USER, "DecryptCustomerUser", s);

        CustomerUserInfo user = (CustomerUserInfo)XMLGenerator.Deserialize(typeof(CustomerUserInfo), s);

        user.Customer.ID = customerID;
        switch (typeID)
        {
        case 1:    //新建
            ret = this.GetCustomerService().InsertCustomerUserFromCP(user);
            break;

        case 2:    //修改
            ret = this.GetCustomerService().ModifyCustomerUserFromCP(user);
            break;

        case 3:    //启用
            ret = this.GetCustomerService().EnableCustomerUserFromCP(user);
            break;

        case 4:    //停用
            ret = this.GetCustomerService().DisableCustomerUserFromCP(user);
            break;

        case 5:    //修改密码
            ret = this.GetCustomerService().ModifyCustomerUserPasswordFromCP(user);
            break;

        default:
            ret = false;
            break;
        }
        this.log(LogLevel.INFO, FunctionName.WS_SYN_USER, MessageType.RESULT, ret.ToString());
        return(ret);
    }