Ejemplo n.º 1
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);
        }