コード例 #1
0
ファイル: OAuthResponce.cs プロジェクト: AzarinSergey/learn
        public static void AuthOrRegCustomer(Customer customer, string identifier)
        {
            if (!CustomerService.IsExistOpenIdLinkCustomer(identifier))
            {
                if (!CustomerService.CheckCustomerExist(customer.EMail))
                {
                    customer.Id = CustomerService.InsertNewCustomer(customer);
                    var clsParam = new ClsMailParamOnRegistration
                    {
                        FirstName = customer.FirstName,
                        LastName = customer.LastName,
                        RegDate = AdvantShop.Localization.Culture.ConvertDate(DateTime.Now),
                        Password = customer.Password,
                        Subsrcibe = customer.SubscribedForNews
                                        ? Resources.Resource.Client_Registration_Yes
                                        : Resources.Resource.Client_Registration_No,
                        ShopURL = SettingsMain.SiteUrl
                    };

                    string message = SendMail.BuildMail(clsParam);

                    SendMail.SendMailNow(SettingsMail.EmailForRegReport,
                                              SettingsMain.SiteUrl + " - " +
                                              string.Format(Resources.Resource.Client_Registration_RegSuccessful, customer.EMail),
                                              message, true);
                }
                else
                {
                    customer = CustomerService.GetCustomerByEmail(customer.EMail);
                }
                CustomerService.AddOpenIdLinkCustomer(customer.Id, identifier);
                customer = CustomerService.GetCustomerByEmail(customer.EMail);
            }
            else
            {
                customer = CustomerService.GetCustomerByOpenAuthIdentifier(identifier);
            }

            AdvantShop.Security.AuthorizeService.AuthorizeTheUser(customer.EMail, customer.Password, true);
        }
コード例 #2
0
ファイル: Customer.cs プロジェクト: AzarinSergey/learn
        public static Customer GetFromSqlDataReader(SqlDataReader reader)
        {
            var customer = new Customer
            {
                Id = SQLDataHelper.GetGuid(reader, "CustomerID"),
                CustomerGroupId = SQLDataHelper.GetInt(reader, "CustomerGroupId", 0),
                EMail = SQLDataHelper.GetString(reader, "EMail"),
                FirstName = SQLDataHelper.GetString(reader, "FirstName"),
                LastName = SQLDataHelper.GetString(reader, "LastName"),
                RegistrationDateTime = SQLDataHelper.GetDateTime(reader, "RegistrationDateTime"),
                SubscribedForNews = SQLDataHelper.GetBoolean(reader, "Subscribed4News"),
                Phone = SQLDataHelper.GetString(reader, "Phone"),
                Password = SQLDataHelper.GetString(reader, "Password"),
                CustomerRole = (Role)SQLDataHelper.GetInt(reader, "CustomerRole"),
                PriceType = SQLDataHelper.GetString(reader, "PriceType").ToPriceType(),
                ClientId = SQLDataHelper.GetInt(reader, "ClientId")
            };

            return customer;
        }
コード例 #3
0
ファイル: OAuthResponce.cs プロジェクト: AzarinSergey/learn
 public static void AuthOrRegCustomer(Customer customer)
 {
     AuthOrRegCustomer(customer, customer.EMail);
 }
コード例 #4
0
ファイル: OAuthResponce.cs プロジェクト: AzarinSergey/learn
        public static Customer GetCustomerParameters(HttpRequest request)
        {
            if (!string.IsNullOrEmpty(request["openid.op_endpoint"]) && request["openid.op_endpoint"].Contains("google"))
            {
                var customer = new Customer { CustomerGroupId = 1, Password = Guid.NewGuid().ToString() };
                if (!string.IsNullOrEmpty(request["openid.ext1.value.firstname"]))
                {
                    customer.FirstName = HttpUtility.UrlDecode(request["openid.ext1.value.firstname"]);
                }
                if (!string.IsNullOrEmpty(request["openid.ext1.value.lastname"]))
                {
                    customer.LastName = HttpUtility.UrlDecode(request["openid.ext1.value.lastname"]);
                }
                if (!string.IsNullOrEmpty(request["openid.ext1.value.email"]))
                {
                    customer.EMail = HttpUtility.UrlDecode(request["openid.ext1.value.email"]);
                }
                else
                {
                    if (!string.IsNullOrEmpty(HttpUtility.UrlDecode(request["openid.sreg.firstname"])))
                    {
                        customer.EMail =
                           HttpUtility.UrlDecode(request["openid.sreg.firstname"]).Replace(" ", "_") + "@temp.google";
                    }
                    else
                    {
                        customer.EMail = AdvantShop.Strings.GetRandomString(8) + "@temp.google";
                    }
                }

                return customer;
            }
            if (!string.IsNullOrEmpty(request["openid.op_endpoint"]) && request["openid.op_endpoint"].Contains("yandex"))
            {
                var customer = new Customer { CustomerGroupId = 1, Password = Guid.NewGuid().ToString() };

                if (!string.IsNullOrEmpty(request["openid.sreg.fullname"]))
                {
                    customer.FirstName = HttpUtility.UrlDecode(request["openid.sreg.fullname"]);
                }
                if (!string.IsNullOrEmpty(request["openid.sreg.email"]))
                {
                    customer.EMail = HttpUtility.UrlDecode(request["openid.sreg.email"]);
                }
                else
                {
                    if (!string.IsNullOrEmpty(HttpUtility.UrlDecode(request["openid.sreg.fullname"])))
                    {
                        customer.EMail = HttpUtility.UrlDecode(request["openid.sreg.fullname"]).Replace(" ", "_") + "@temp.yandex";
                    }
                    else
                    {
                        customer.EMail = AdvantShop.Strings.GetRandomString(8) + "@temp.yandex";
                    }
                }
                return customer;
            }
            if (!string.IsNullOrEmpty(request["openid.op_endpoint"]) && request["openid.op_endpoint"].Contains("mail"))
            {
                var customer = new Customer { CustomerGroupId = 1, Password = Guid.NewGuid().ToString() };

                if (!string.IsNullOrEmpty(request["openid.sreg.fullname"]))
                {
                    customer.FirstName = HttpUtility.UrlDecode(request["openid.sreg.fullname"]);
                }
                if (!string.IsNullOrEmpty(request["openid.sreg.email"]))
                {
                    customer.EMail = HttpUtility.UrlDecode(request["openid.sreg.email"]);
                }
                else
                {
                    if (!string.IsNullOrEmpty(HttpUtility.UrlDecode(request["openid.sreg.fullname"])))
                    {
                        customer.EMail =
                        HttpUtility.UrlDecode(request["openid.sreg.fullname"]).Replace(" ", "_") + "@temp.mail";
                    }
                    else
                    {
                        customer.EMail = AdvantShop.Strings.GetRandomString(8) + "@temp.mail";
                    }
                }
                return customer;
            }
            return null;
        }
コード例 #5
0
 public static void WriteCookie(Customer customer)
 {
     var collection = new NameValueCollection
                             {
                                 {"cUserName", customer.EMail},
                                 {"cUserPWD", customer.Password},
                                 {"cUserId", customer.Id.ToString()}
                             };
     CommonHelper.SetCookieCollection(MCookieCollectionName, collection, new TimeSpan(7, 0, 0, 0));
 }
コード例 #6
0
ファイル: FacebookOauth.cs プロジェクト: AzarinSergey/learn
 public static void AuthOrRegCustomer(Customer customer)
 {
     OAuthResponce.AuthOrRegCustomer(customer);
 }
コード例 #7
0
ファイル: CustomerService.cs プロジェクト: AzarinSergey/learn
        public static int UpdateCustomer(Customer customer)
        {
            if (CustomerSubscribe(customer.Id) != customer.SubscribedForNews)
            {
                var modules = AttachedModules.GetModules(AttachedModules.EModuleType.SendMails).Where(item => ((ISendMails)Activator.CreateInstance(item, null)).IsActive);
                if (customer.SubscribedForNews)
                {
                    foreach (var moduleType in modules)
                    {
                        var moduleObject = (ISendMails)Activator.CreateInstance(moduleType, null);
                        moduleObject.SubscribeEmail(customer.EMail);
                    }
                }
                else
                {
                    foreach (var moduleType in modules)
                    {
                        var moduleObject = (ISendMails)Activator.CreateInstance(moduleType, null);
                        moduleObject.UnsubscribeEmail(customer.EMail);
                    }
                }
            }

            SQLDataAccess.ExecuteNonQuery("[Customers].[sp_UpdateCustomerInfo]", CommandType.StoredProcedure,
                                          new SqlParameter("@CustomerID", customer.Id),
                                          new SqlParameter("@FirstName", customer.FirstName),
                                          new SqlParameter("@LastName", customer.LastName),
                                          new SqlParameter("@Phone", customer.Phone),
                                          new SqlParameter("@Email", customer.EMail),
                                          new SqlParameter("@Subscribed4News", customer.SubscribedForNews),
                                          new SqlParameter("@CustomerGroupId", customer.CustomerGroupId == 0 ? (object) DBNull.Value : customer.CustomerGroupId),
                                          new SqlParameter("@CustomerRole", customer.CustomerRole),
                                          new SqlParameter("@PriceType", customer.PriceType.ToString()),
                                          new SqlParameter("@ClientId", customer.ClientId)
                );
            return 0;
        }
コード例 #8
0
ファイル: CustomerService.cs プロジェクト: AzarinSergey/learn
        public static Guid InsertNewCustomer(Customer customer)
        {
            if (CheckCustomerExist(customer.EMail))
            {
                return Guid.Empty;
            }
            var temp = SQLDataAccess.ExecuteScalar("[Customers].[sp_AddCustomer]", CommandType.StoredProcedure,
                                                new SqlParameter("@CustomerGroupID", customer.CustomerGroupId),
                                                new SqlParameter("@Password", SecurityHelper.GetPasswordHash(customer.Password)),
                                                new SqlParameter("@FirstName", customer.FirstName),
                                                new SqlParameter("@LastName", customer.LastName),
                                                new SqlParameter("@Phone", string.IsNullOrEmpty(customer.Phone) ? (object)DBNull.Value : customer.Phone),
                                                new SqlParameter("@RegistrationDateTime", DateTime.Now),
                                                new SqlParameter("@Subscribed4News", customer.SubscribedForNews),
                                                new SqlParameter("@Email", customer.EMail),
                                                new SqlParameter("@CustomerRole", customer.CustomerRole),
                                                new SqlParameter("@PriceType", customer.PriceType.ToString()),
                                                new SqlParameter("@ClientId", customer.ClientId),
                                                new SqlParameter("@SysReg", (object)DBNull.Value) // (NULL или 0 - клиент зарегистрирован через сайт, 1-зарегистрирован менеджером через систему учета)
                                                ).ToString();

            if (customer.SubscribedForNews)
            {
                var modules = AttachedModules.GetModules(AttachedModules.EModuleType.SendMails).Where(item => ((ISendMails)Activator.CreateInstance(item, null)).IsActive);
                foreach (var moduleType in modules)
                {
                    var moduleObject = (ISendMails)Activator.CreateInstance(moduleType, null);
                    moduleObject.SubscribeEmail(customer.EMail);
                }
            }

            customer.Id = new Guid(temp);
            return customer.Id;
        }