Example #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);
    }
Example #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);
    }
Example #4
0
    //加载客户数据
    private CustomerInfo getCustomerInfo()
    {
        try
        {
            var customerService = this.GetCustomerService();
            var customerInfo    = new CustomerInfo();
            customerInfo.Code              = tbCode.Text;
            customerInfo.Name              = tbname.Text;
            customerInfo.EnglishName       = tbEnglishName.Text;
            customerInfo.StartDate         = tbStartDate.Value;
            customerInfo.Address           = tbAddress.Text;
            customerInfo.PostCode          = tbPostcode.Text;
            customerInfo.Contacter         = tbContacter.Text;
            customerInfo.Fax               = tbFax.Text;
            customerInfo.Tel               = tbTel.Text;
            customerInfo.Cell              = tbCell.Text;
            customerInfo.Email             = tbEmail.Text;
            customerInfo.Memo              = tbRemark.Text;
            customerInfo.StatusDescription = tbStatus.Text;
            customerInfo.IsALD             = Convert.ToInt32(cbIsALD.SelectedValue);
            //customerInfo.DataDeployId = cbCustomer.SelectedValue;
            var depIds    = GetSelectedIds();
            var depIdList = depIds.Split(',');
            if (depIdList != null && depIdList.Length > 1)
            {
                this.InfoBox.ShowPopError("只能选择一个连接信息!");
                return(null);
            }
            if (depIdList != null && depIdList.Length == 1)
            {
                customerInfo.DataDeployId = depIdList[0];
            }

            var tmpDepQuery = new Hashtable();
            tmpDepQuery["DataDeployId"] = customerInfo.DataDeployId;
            var depItemList = customerService.GetTDataDeployList(tmpDepQuery, 1, 0);
            if (depItemList == null || depItemList.Count == 0)
            {
                this.InfoBox.ShowPopError("请选择连接信息!");
                return(null);
            }
            var depItemObj = depItemList[0];


            var connection = new CustomerConnectInfo();
            connection.Customer.ID      = customerInfo.ID;
            connection.AccessURL        = depItemObj.access_url;
            connection.DBName           = depItemObj.db_name;
            connection.DBPassword       = depItemObj.db_pwd;
            connection.DBServer         = depItemObj.db_server;
            connection.DBUser           = depItemObj.db_user;
            connection.KeyFile          = depItemObj.key_file;
            connection.MaxShopCount     = depItemObj.max_shop_count;
            connection.MaxTerminalCount = depItemObj.max_terminal_count;
            connection.MaxUserCount     = depItemObj.max_user_count;
            customerInfo.Connect        = connection;
            List <CustomerMenuInfo> menus = new List <CustomerMenuInfo>();
            foreach (TreeNode item in tvMenu.CheckedNodes)
            {
                menus.Add(new CustomerMenuInfo {
                    Menu = new MenuInfo {
                        ID = item.Value
                    }
                });
            }
            customerInfo.Menus = menus.Count == 0 ? null : menus;
            if (Convert.ToInt32(ViewState["action"]) == 2)
            {
                var creater = new UserOperateInfo();
                creater.Name            = tbCreater.Text;
                customerInfo.Creater    = creater;
                customerInfo.CreateTime = Convert.ToDateTime(tbCreateTime.Text);
                customerInfo.Status     = 1;//状态正常
            }
            else
            {
                customerInfo.ID = this.Request.QueryString["customer_id"];
                var editor = new UserOperateInfo();
                editor.Name               = SessionManager.CurrentLoggingSession.CustomerName;
                customerInfo.LastEditor   = editor;
                customerInfo.LastEditTime = DateTime.Now;
            }
            return(customerInfo);
        }
        catch (Exception ex)
        {
            PageLog.Current.Write(ex);
            this.InfoBox.ShowPopError("加载数据出错!");
            return(null);
        }
    }
    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);
    }
Example #6
0
    //加载客户数据
    private CustomerInfo getCustomerInfo()
    {
        try
        {
            var customerService = this.GetCustomerService();
            var customerInfo    = new CustomerInfo();
            customerInfo.Code              = tbCode.Text;
            customerInfo.Name              = tbname.Text;
            customerInfo.EnglishName       = tbEnglishName.Text;
            customerInfo.StartDate         = tbStartDate.Value;
            customerInfo.Address           = tbAddress.Text;
            customerInfo.PostCode          = tbPostcode.Text;
            customerInfo.Contacter         = tbContacter.Text;
            customerInfo.Fax               = tbFax.Text;
            customerInfo.Tel               = tbTel.Text;
            customerInfo.Cell              = tbCell.Text;
            customerInfo.Email             = tbEmail.Text;
            customerInfo.Memo              = tbRemark.Text;
            customerInfo.StatusDescription = tbStatus.Text;
            if (tbUnits.Text.Trim().Length > 0 && isNumberic(tbUnits.Text.Trim()))
            {
                customerInfo.Units = Convert.ToInt32(tbUnits.Text.Trim());
            }
            else
            {
                customerInfo.Units = -1;
            }
            //customerInfo.IsALD = Convert.ToInt32(cbIsALD.SelectedValue);
            //customerInfo.DataDeployId = cbCustomer.SelectedValue;
            var depIds    = GetSelectedIds();
            var depIdList = depIds.Split(',');
            if (depIdList != null && depIdList.Length > 1)
            {
                this.InfoBox.ShowPopError("只能选择一个连接信息!");
                return(null);
            }
            if (depIdList != null && depIdList.Length == 1)
            {
                customerInfo.DataDeployId = depIdList[0];
            }

            var tmpDepQuery = new Hashtable();
            tmpDepQuery["DataDeployId"] = customerInfo.DataDeployId;
            var depItemList = customerService.GetTDataDeployList(tmpDepQuery, 1, 0);//为什么还要这一步,前面取的已经是数据库配置信息了。
            //再次判断数据库里是否有这个链接
            if (depItemList == null || depItemList.Count == 0)
            {
                this.InfoBox.ShowPopError("请选择连接信息!");
                return(null);
            }
            var depItemObj = depItemList[0];//从数据库里获取完整的配置信息


            var connection = new CustomerConnectInfo();
            connection.Customer.ID      = customerInfo.ID;
            connection.AccessURL        = depItemObj.access_url;//从完整的数据库配置信息里,取数据。
            connection.DBName           = depItemObj.db_name;
            connection.DBPassword       = depItemObj.db_pwd;
            connection.DBServer         = depItemObj.db_server;
            connection.DBUser           = depItemObj.db_user;
            connection.KeyFile          = depItemObj.key_file;
            connection.MaxShopCount     = depItemObj.max_shop_count;
            connection.MaxTerminalCount = depItemObj.max_terminal_count;
            connection.MaxUserCount     = depItemObj.max_user_count;
            customerInfo.Connect        = connection;
            #region 菜单信息
            List <CustomerMenuInfo> menus = new List <CustomerMenuInfo>();
            foreach (TreeNode item in tvMenu.CheckedNodes)
            {
                menus.Add(new CustomerMenuInfo {
                    Menu = new MenuInfo {
                        ID = item.Value
                    }
                });
            }
            customerInfo.Menus = menus.Count == 0 ? null : menus;
            #endregion
            #region 操作信息
            if (Convert.ToInt32(ViewState["action"]) == 2)
            {
                var creater = new UserOperateInfo();
                creater.Name            = tbCreater.Text;
                customerInfo.Creater    = creater;
                customerInfo.CreateTime = Convert.ToDateTime(tbCreateTime.Text);
                customerInfo.Status     = 1;//状态正常
            }
            else
            {
                customerInfo.ID = this.Request.QueryString["customer_id"];
                var editor = new UserOperateInfo();
                editor.Name               = SessionManager.CurrentLoggingSession.CustomerName;//修改人用当前登录人信息
                customerInfo.LastEditor   = editor;
                customerInfo.LastEditTime = DateTime.Now;
            }
            #endregion
            //添加UnitID ,运营商ID
            if (SessionManager.CurrentLoggingSession.unit_id != "")//如果当前的用户是运营商客户,那么不让其选择运营商
            {
                customerInfo.UnitId = SessionManager.CurrentLoggingSession.unit_id;
            }
            else
            {
                var unitIds = GetUnitSelectedIds();
                if (unitIds != null)
                {
                    var unitIdsList = unitIds.Split(',');
                    if (unitIdsList != null && unitIdsList.Length > 1)
                    {
                        this.InfoBox.ShowPopError("只能选择一个运营商!");
                        return(null);
                    }
                    if (unitIdsList != null && unitIdsList.Length == 1)
                    {
                        customerInfo.UnitId = unitIdsList[0];
                    }
                }
            }
            //这里要根据登录账户本身带不带unitId,如果带,就用账户自身的unitId,如果不带就用上面的id

            return(customerInfo);
        }
        catch (Exception ex)
        {
            PageLog.Current.Write(ex);
            this.InfoBox.ShowPopError("加载数据出错!");
            return(null);
        }
    }