Beispiel #1
0
        //public void SaveUserToTurboTick(TurnKeyBrokerSignUpDataContext dataContext, RegistrationInfo info)
        //{
        //    if (dataContext == null)
        //        dataContext = new TurnKeyBrokerSignUpDataContext();

        //    var _account = (from s in dataContext.tb_accounts
        //                        //  where s.email_address == info.EmailAddress
        //                    where s.account_id == info.AccountId
        //                      && s.active == true
        //                    select s).FirstOrDefault();

        //    if (_account != null)
        //    {
        //        tb_address address = GetAddress(dataContext, info.AccountId, "Permanent");

        //        string state = string.Empty;
        //        if (address.country_id == 1)
        //        {
        //            var states = (from s in dataContext.tb_states
        //                          where s.state_id == int.Parse(address.state)
        //                          && s.active == true
        //                          select s).FirstOrDefault();
        //            if (states != null)
        //                state = states.state_initial;
        //        }
        //        else
        //        {
        //            state = address.state;
        //        }


        //        string valid = "";
        //        string managerUsername = System.Configuration.ConfigurationManager.AppSettings["TurboTickDemoManagerUsername"].ToString();
        //        string managerPassword = System.Configuration.ConfigurationManager.AppSettings["TurboTickDemoManagerPassword"].ToString();

        //        valid = SingleSignOnLib.SingleSignOnOverHttp.RequestManagerLogin(managerUsername, managerPassword, SingleSignOnClien.Web.Common.TurboTickSingleSignOn);

        //        if (valid.ToLower().Equals("yes"))
        //        {
        //            SingleSignOnLib.SingleSignOnUser newUser = new SingleSignOnLib.SingleSignOnUser();
        //            SingleSignOnLib.SingleSignOnAccount account = new SingleSignOnLib.SingleSignOnAccount();
        //            newUser.DisableUser = "******";
        //            newUser.Email = _account.email_address;
        //            newUser.Firstname = address.first_name;
        //            newUser.Lastname = address.last_name;
        //            newUser.Password = _account.password;//SingleSignOnLib.SHA.EncryptSHA256(_account.password);
        //            newUser.Phone = address.work_phone;
        //            newUser.DisableUser = "******";
        //            newUser.WebEdition = "true";
        //            newUser.DesktopEdition = "true";
        //            newUser.IsUpdate = false;
        //            newUser.Username = _account.customer_id;
        //            account.Account = _account.customer_id;
        //            account.City = address.city;
        //            account.FirstName = address.first_name;
        //            account.LastName = address.last_name;
        //            account.Address = address.address_1;
        //            account.BPMultiplier = int.Parse(System.Configuration.ConfigurationManager.AppSettings["txtBPMultiplier"].ToString());
        //            account.MarginBuyingPower = decimal.Parse(System.Configuration.ConfigurationManager.AppSettings["txtBuyingPower"].ToString());
        //            account.MasterAccount = "XXXXXXXX";
        //            account.MaximumOrderSize = int.Parse(System.Configuration.ConfigurationManager.AppSettings["txtAccMaxOrderSize"].ToString());
        //            account.OptionsTrading = "true";
        //            account.RoutingCommisionType = System.Configuration.ConfigurationManager.AppSettings["txtAccRoutingComissionTypes"].ToString();
        //            account.State = state;
        //            account.TradingSuspended = "false";

        //            account.Zip = address.zipcode;
        //            newUser.Account = account;
        //            newUser.MobileEdition = "true";
        //            newUser.WebEditionPro = "true";
        //            account.Equity = 0;
        //            account.NightBuyingPower = 0;
        //            if (SingleSignOnLib.SingleSignOnOverHttp.SendNewSingleSignOnUser(SingleSignOnClien.Web.Common.TurboTickSingleSignOn + "?usercreation=1&managerName=" + System.Configuration.ConfigurationManager.AppSettings["TurboTickDemoManagerUsername"].ToString(), System.Configuration.ConfigurationManager.AppSettings["TurboTickDemoManagerUsername"].ToString(), newUser).Equals("success"))
        //            {
        //                _account.turbo_tick_log = string.Format("User '{0}' with account '{1}' was created. Operation succeeded!", newUser.Username, account.Account);
        //                dataContext.SubmitChanges();
        //            }
        //            else
        //            {
        //                _account.turbo_tick_log = "Operation failed! Please retry the operation";
        //                dataContext.SubmitChanges();
        //            }


        //        }
        //    }

        //}

        public void SaveUserToPortal(TurnKeyBrokerSignUpDataContext dataContext, RegistrationInfo info, string StoreURI)

        {
            if (dataContext == null)
            {
                dataContext = new TurnKeyBrokerSignUpDataContext();
            }

            var account = (from s in dataContext.tb_accounts
                           // where s.email_address == info.EmailAddress
                           where s.account_id == info.AccountId

                           && s.active == true
                           select s).FirstOrDefault();

            if (account != null)
            {
                tb_address address = GetAddress(dataContext, info.AccountId, "Permanent");
                string     tradeZeroApplicationId = dataContext.aspnet_Applications.Where(a => a.ApplicationName == "tradezero").FirstOrDefault().ApplicationId.ToString();

                if (!string.IsNullOrEmpty(tradeZeroApplicationId))
                {
                    using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["TradeZeroSQLProvider"].ConnectionString))
                    {
                        string strUserCreateUser = "******" + tradeZeroApplicationId + "','" + account.customer_id + "',0,'" + DateTime.Now.Date.ToString("yyyy-MM-dd HH:mm:ss") + "','" + Guid.NewGuid() + "'";
                        conn.Open();
                        System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand();
                        command.CommandType = System.Data.CommandType.Text;
                        command.Connection  = conn;
                        command.CommandText = strUserCreateUser;
                        command.ExecuteNonQuery();

                        Guid   guidNewUserId = dataContext.aspnet_Users.Where(u => u.UserName == account.customer_id).FirstOrDefault().UserId;
                        string newUserID     = guidNewUserId.ToString();

                        store_base sb      = dataContext.store_bases.Where(_sb => _sb.name == StoreURI).FirstOrDefault();
                        int        storeId = 1;
                        if (sb != null)
                        {
                            storeId = sb.storeId;
                        }

                        var _aspNetUser = dataContext.aspnet_Users.Where(a => a.UserId == guidNewUserId).FirstOrDefault();
                        if (_aspNetUser != null)
                        {
                            _aspNetUser.storeId = storeId;
                            dataContext.SubmitChanges();
                        }

                        var emailAddress = account.email_address.Replace("@", "_" + account.customer_id + "@");
                        if (!string.IsNullOrEmpty(newUserID))
                        {
                            string strMembershipCreateUser = "******" + account.customer_id + "','" + account.password + "','1234','" + emailAddress + "',NULL,NULL,1,'" + DateTime.Now.Date.ToString("yyyy-MM-dd HH:mm:ss") + "','" + DateTime.Now.Date.ToString("yyyy-MM-dd HH:mm:ss") + "',1,0,'" + newUserID + "'";
                            command.CommandText = strMembershipCreateUser;
                            command.Connection  = conn;
                            command.CommandType = System.Data.CommandType.Text;
                            command.ExecuteNonQuery();
                        }
                        command.Dispose();
                        conn.Close();
                    }
                }
            }
        }
Beispiel #2
0
        public bool SaveAddress(TurnKeyBrokerSignUpDataContext dataContext, RegistrationInfo info, string type, string title, string first_name, string last_name, string middle_name, string suffix, string address_1, string address_2,
                                string city, int stateId, string otherState, string zipCode, int countryId, bool is_address_last_one_year, int martial_status_id, string work_phone, string num_dependents, bool isCoApplicant, string business_tel, string fax, bool isDebug)
        {
            try
            {
                int update = 0;
                if (dataContext == null)
                {
                    dataContext = new TurnKeyBrokerSignUpDataContext();
                }
                var accTypeId  = GetAddressType(dataContext, type);
                var tb_address = dataContext.tb_addresses.Where(t => t.account_id == info.AccountId && t.address_type_id == accTypeId).FirstOrDefault();

                tb_address address;
                if (tb_address != null)
                {
                    if (info.AccountType == 2)
                    {
                        if (isCoApplicant == true)
                        {
                            address = new tb_address();
                        }
                        else
                        {
                            address = tb_address;
                            update  = 1;
                        }
                    }
                    else
                    {
                        address = tb_address;
                        update  = 1;
                    }
                }
                else
                {
                    address = new tb_address();
                }
                address.account_id         = info.AccountId;
                address.address_type_id    = accTypeId;
                address.title              = title;
                address.first_name         = first_name;
                address.last_name          = last_name;
                address.middle_name        = middle_name;
                address.suffix             = suffix;
                address.address_1          = address_1;
                address.address_2          = address_2;
                address.city               = city;
                address.business_telephone = business_tel;
                address.fax = fax;
                if (countryId == 1)
                {
                    address.state = stateId.ToString();
                }
                else
                {
                    address.state = otherState;
                }

                address.zipcode    = zipCode;
                address.country_id = countryId;
                address.is_address_last_one_year = is_address_last_one_year;
                address.martial_status_id        = martial_status_id;
                address.work_phone     = work_phone;
                address.num_dependents = num_dependents;
                address.email_address  = info.EmailAddress;
                address.date_created   = DateTime.Now;
                address.is_coapplicant = isCoApplicant;
                if (update == 0)
                {
                    dataContext.tb_addresses.InsertOnSubmit(address);
                    dataContext.SubmitChanges();
                }
                else
                {
                    if (!isDebug)
                    {
                        dataContext.SubmitChanges();
                    }
                    //dataContext.SubmitChanges();
                }


                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }