Ejemplo n.º 1
0
        //+------------------------------------------------------------------+
        //| Get user info string                                             |
        //+------------------------------------------------------------------+
        public bool GetUserInfo(UInt64 login, out string str)
        {
            str = string.Empty;
            //--- request user from server
            m_user.Clear();
            MTRetCode res = m_manager.UserRequest(login, m_user);

            if (res != MTRetCode.MT_RET_OK)
            {
                m_manager.LoggerOut(EnMTLogCode.MTLogErr, "UserRequest error ({0})", res);
                return(false);
            }
            //--- format string
            str = string.Format("{0},{1},{2},1:{3}", m_user.Name(), m_user.Login(), m_user.Group(), m_user.Leverage());
            //---
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 本段代码批量添加user,本来是用来测试UserCreateArray函数的,但是没感觉这个函数有什么用
        /// </summary>
        /// <param name="length"></param>
        /// <param name="group"></param>
        /// <param name="levelage"></param>
        /// <param name="mainPassword"></param>
        /// <param name="readonlyPassword"></param>
        /// <param name="userNameStartWords"></param>
        /// <returns></returns>
        public List <string> UserAddArray(uint length, string group, uint levelage, string mainPassword, string readonlyPassword, string userNameStartWords = null)
        {
            List <string> mtRetCodeStrings = new List <string>();

            using (CIMTUserArray userArray = this.m_manager.UserCreateArray())
            {
                for (uint iCount = 0; iCount < length; iCount++)
                {
                    using (CIMTUser user = this.m_manager.UserCreate())
                    {
                        if (userNameStartWords != null)
                        {
                            user.Name(userNameStartWords + (iCount + 1).ToString());
                        }
                        user.Leverage(levelage);
                        user.Group(group);
                        MTRetCode mtRetCode = this.m_manager.UserAdd(user, mainPassword, readonlyPassword);
                        userArray.Add(user);
                        mtRetCodeStrings.Add(mtRetCode.ToString());
                    }
                }
            }
            return(mtRetCodeStrings);
        }
Ejemplo n.º 3
0
        //public MTRetCode UserAdd(string userName, string mainPassword, string readonlyPassword)
        //{
        //    MTRetCode mtRetCode = MTRetCode.MT_RET_ERROR;
        //    using (CIMTUser user = this.m_manager.UserCreate())
        //    {
        //        user.Name(userName);
        //        user.Leverage(100);
        //        user.Group(@"demo\demoforex");
        //        mtRetCode = this.m_manager.UserAdd(user, mainPassword, readonlyPassword);
        //    }

        //    return mtRetCode;
        //}

        public MTRetCode UserAdd(string group, uint levelage, string mainPassword,
                                 string readonlyPassword,
                                 string userName = null,
                                 ulong?loginID   = null,
                                 CIMTUser.EnUsersRights?rights = null,
                                 string company       = null,
                                 string account       = null,
                                 string country       = null,
                                 uint?language        = null,
                                 string city          = null,
                                 string state         = null,
                                 string zipCode       = null,
                                 string address       = null,
                                 string phone         = null,
                                 string email         = null,
                                 string id            = null,
                                 string status        = null,
                                 string comment       = null,
                                 uint?color           = null,
                                 string phonePassword = null,
                                 ulong?agent          = null,
                                 string leadSource    = null,
                                 string leadCampaign  = null,
                                 ushort?app_id        = null,
                                 byte?idApp           = null,
                                 long?valueLong       = null,
                                 ulong?valueUlong     = null,
                                 double?valueDouble   = null)
        {
            MTRetCode mtRetCode = MTRetCode.MT_RET_ERROR;

            //string mqid = null;
            using (CIMTUser user = this.m_manager.UserCreate())
            {
                if (userName != null)
                {
                    mtRetCode = user.Name(userName);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                mtRetCode = user.Leverage(levelage);
                if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                {
                    return(mtRetCode);
                }
                mtRetCode = user.Group(group);
                if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                {
                    return(mtRetCode);
                }
                if (loginID != null)
                {
                    mtRetCode = user.Login(loginID.Value);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (rights != null)
                {
                    mtRetCode = user.Rights(rights.Value);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (company != null)
                {
                    mtRetCode = user.Company(company);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (account != null)
                {
                    mtRetCode = user.Account(account);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (country != null)
                {
                    mtRetCode = user.Country(country);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (language != null)
                {
                    mtRetCode = user.Language(language.Value);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (city != null)
                {
                    mtRetCode = user.City(city);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (state != null)
                {
                    mtRetCode = user.State(state);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (zipCode != null)
                {
                    mtRetCode = user.ZIPCode(zipCode);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (address != null)
                {
                    mtRetCode = user.Address(address);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (phone != null)
                {
                    mtRetCode = user.Phone(phone);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (email != null)
                {
                    mtRetCode = user.EMail(email);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (id != null)
                {
                    mtRetCode = user.ID(id);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (status != null)
                {
                    mtRetCode = user.Status(status);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (comment != null)
                {
                    mtRetCode = user.Comment(comment);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (color != null)
                {
                    mtRetCode = user.Color(color.Value);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (phonePassword != null)
                {
                    mtRetCode = user.PhonePassword(phonePassword);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (agent != null)
                {
                    mtRetCode = user.Agent(agent.Value);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (leadSource != null)
                {
                    mtRetCode = user.LeadSource(leadSource);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (leadCampaign != null)
                {
                    mtRetCode = user.LeadCampaign(leadCampaign);
                    if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                    {
                        return(mtRetCode);
                    }
                }
                if (app_id != null && idApp != null)
                {
                    if (valueLong != null)
                    {
                        mtRetCode = user.ApiDataSet(app_id.Value, idApp.Value, valueLong.Value);
                        if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                        {
                            return(mtRetCode);
                        }
                    }
                    else if (valueUlong != null)
                    {
                        mtRetCode = user.ApiDataSet(app_id.Value, idApp.Value, valueUlong.Value);
                        if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                        {
                            return(mtRetCode);
                        }
                    }
                    else if (valueDouble != null)
                    {
                        mtRetCode = user.ApiDataSet(app_id.Value, idApp.Value, valueDouble.Value);
                        if (mtRetCode != MTRetCode.MT_RET_OK && mtRetCode != MTRetCode.MT_RET_OK_NONE)
                        {
                            return(mtRetCode);
                        }
                    }
                }
                mtRetCode = this.m_manager.UserAdd(user, mainPassword, readonlyPassword);
            }
            return(mtRetCode);
        }