public void OnGet()
        {
            var userId = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            List <Model.Company> AppCompanies = _context.Company.ToList();

            foreach (Model.Company U in AppCompanies)
            {
                if (_userManager.GetRolesAsync(_userManager.FindByIdAsync(userId).Result).Result.Contains("CompanyAdmin"))
                {
                    if (_userManager.FindByIdAsync(userId).Result.CompanyId == U.Id)
                    {
                        CompanyStore X = new CompanyStore
                        {
                            Id           = U.Id,
                            CompanyLogo  = U.CompanyLogo,
                            CompanyName  = U.CompanyName,
                            CreationDate = U.CreationDate,
                        };
                        Companies.Add(X);
                    }
                }
                else
                {
                    CompanyStore X = new CompanyStore
                    {
                        Id           = U.Id,
                        CompanyLogo  = U.CompanyLogo,
                        CompanyName  = U.CompanyName,
                        CreationDate = U.CreationDate,
                    };
                    Companies.Add(X);
                }
            }
        }
Exemple #2
0
        public ActionResult SaveStore(int companyId, int storeId, string storename, string storetel, int cityId)
        {
            bool isnew = false;

            if (string.IsNullOrEmpty(storename) || companyId == 0)
            {
                return(Content("0"));
            }
            CompanyStore companystore = ncBase.CurrentEntities.CompanyStore.Where(o => o.StoreId == storeId).FirstOrDefault();

            if (companystore.IsNull())
            {
                isnew                = true;
                companystore         = new CompanyStore();
                companystore.Address = "";
            }
            companystore.CityID    = cityId;
            companystore.Tel       = storetel;
            companystore.CompanyId = companyId;
            companystore.StoreName = storename;

            if (isnew)
            {
                ncBase.CurrentEntities.AddToCompanyStore(companystore);
            }
            ncBase.CurrentEntities.SaveChanges();

            return(Content(companystore.StoreId.ToString()));
        }
Exemple #3
0
        public ActionResult Index(string menu = "", string url = "")
        {
            PublicUserModel loginUser = this.GetLoginUser();

            if (loginUser.IsNull())
            {
                return(Redirect("/"));
            }
            #region (每天一次)每天访问登陆后的首页就增加一次统计,避免cooike自动登录的 统计不到登陆明细
            if (loginUser != null && loginUser.UserID > 0)
            {
                userBll.HomeIndexAccessStat(loginUser.UserID, loginUser.Name);
            }
            #endregion

            int     companyId = loginUser.IsNoNull()? Convert.ToInt32(loginUser.CompanyId):0;
            Company company   = ncBase.CurrentEntities.Company.Where(c => c.CompanyId == companyId).FirstOrDefault();
            if (company != null)
            {
                ViewBag.CompanyName = company.Name;
            }
            int          storeId      = loginUser.IsNoNull() ? Convert.ToInt32(loginUser.StoreId) : 0;
            CompanyStore companyStore = ncBase.CurrentEntities.CompanyStore.Where(c => c.StoreId == storeId).FirstOrDefault();
            if (companyStore != null)
            {
                ViewBag.CompanyStoreName = companyStore.StoreName;
            }
            ViewBag.Url  = url;
            ViewBag.Menu = menu;
            return(View(loginUser));
        }
Exemple #4
0
    public void ParseJsonTestSimplePasses()
    {
        Debug.Log("Current Directory: " + Application.dataPath);

        string file = Path.Combine(Application.dataPath, "Crawler/data.json");

        Assert.IsTrue(File.Exists(file));
        var companies = CompanyStore.ParseFromFile(file);

        Assert.IsTrue(companies.Count == 22);

        Assert.IsTrue(companies.First().EmployeeCount == 500);
    }
Exemple #5
0
        }                                              //jc


        public RegisterModel(
            UserManager <ApplicationUser> userManager,
            SignInManager <ApplicationUser> signInManager,
            ILogger <RegisterModel> logger,
            IEmailSender emailSender,
            CompanyStore companyStore)
        {
            _userManager   = userManager;
            _signInManager = signInManager;
            _logger        = logger;
            _emailSender   = emailSender;
            CompanyStore   = companyStore; //jc
        }
Exemple #6
0
        public void Init()
        {
            clientStore = new CompanyStore <Company>("CRMContext");

            clientStore = new CompanyStore <Company>();
            Mapper.Initialize(cnfg =>
            {
                cnfg.CreateMap <Company, CompanyEntity>();
                cnfg.CreateMap <CompanyEntity, Company>();
                cnfg.CreateMap <CRMUser, UserProfileEntity>();
                cnfg.CreateMap <UserProfileEntity, CRMUser>();
            });
        }
Exemple #7
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var companyId = Company.Id;       //jc
                CompanyStore.AddCompany(Company); //jc
                var user = new ApplicationUser {
                    UserName = Input.Email, Email = Input.Email, CompanyId = companyId
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("El usuario creó una nueva cuenta con contraseña.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code = code },
                        protocol: Request.Scheme);

                    //var body = _emailBody.GetHtmlBady(callbackUrl, "Htmls\\confirmEmailTemplate.html");
                    await _emailSender.SendEmailAsync(Input.Email, "Confirme su email",
                                                      //body);
                                                      $"Por favor confirme su cuenta <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>haciendo clic aquí</a>.");

                    if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        return(RedirectToPage("RegisterConfirmation", new { email = Input.Email }));
                    }
                    else
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Exemple #8
0
        // GET: Product

        public ActionResult create()
        {
            CompanyStore <Company>   clientStore   = new CompanyStore <Company>();
            CompanyManager <Company> clientManager = new CompanyManager <Company>(clientStore);
            ProductCreateModel       m             = new ProductCreateModel();

            m.Clients = clientManager.GetAllClients();
            m.Clients.Insert(0, new Company()
            {
                CompanyId = 0, Name = "Select Company"
            });
            m.ClientId = "1";

            //    ClientManager< TClient > clientManager = new ClientManager<TClient>();

            return(View(m));
        }
Exemple #9
0
        void Start()
        {
            Companies = CompanyStore.ParseFromFile();

            _initialPositionMap = new Dictionary <string, Transform>(Companies.Count);
            ObjectMap           = new Dictionary <string, GameObject>(Companies.Count);

            foreach (var company in Companies)
            {
                const float y = 1.62f;

                var t = new Vector3(
                    Random.Range(0, 1f),
                    Random.Range(0, 1f),
                    Random.Range(0, 1f)
                    );

                var star = Instantiate(StarPrefab);
                star.transform.position = t;

                _initialPositionMap.Add(company.Id, star.transform);
                ObjectMap.Add(company.Id, star);
            }

            foreach (var o in ObjectMap)
            {
                var starController = (StarController)o.Value.GetComponent <StarController>();
                Debug.Assert(starController != null);
                starController.company = Companies
                                         .Single(p => p.Id == o.Key);

                var relatedSpheres = Companies
                                     .Single(p => p.Id == o.Key)
                                     .Similarities;

                Debug.Log(string.Format("{0} has {1} similiar companies", o.Key, relatedSpheres.Count));

                var relatedSpherePositions = relatedSpheres
                                             .Select(p => _initialPositionMap[p.Key]);

                starController.relatedSpheres = relatedSpherePositions.ToArray();
            }
        }
Exemple #10
0
        public JsonResult InviteRegister(int cityId, string info, string password, string from = "")
        {
            if (String.IsNullOrEmpty(info))
            {
                return(Json(new { status = -1, msg = "无效的参数" }));
            }
            UserModels userModels = new UserModels();

            info       = CryptoUtility.TripleDESDecrypt(info);
            userModels = JsonConvert.DeserializeObject <UserModels>(info);
            string tel = string.IsNullOrEmpty(userModels.Tel) ? "" : StringUtility.StripWhiteSpace(userModels.Tel.Replace("-", ""), false);

            if (tel.StartsWith("0"))
            {
                tel = tel.Substring(1);
            }
            userModels.Tel = tel;
            if (!StringUtility.ValidateMobile(userModels.Tel))
            {
                return(Json(new { status = -1, msg = "手机号码格式不正确" }));
            }
            PublicUser publicUser =
                ncBase.CurrentEntities.PublicUser.Where(o => o.Tel == userModels.Tel).FirstOrDefault();

            if (publicUser.IsNoNull())
            {
                return(Json(new { status = -1, msg = "该手机号码已经注册过了" }));
            }
            publicUser =
                ncBase.CurrentEntities.PublicUser.Where(o => o.Name == userModels.UserName).FirstOrDefault();
            string userName = userModels.UserName;

            if (publicUser.IsNoNull())
            {
                userModels.UserName = userModels.UserName + "_" + userModels.UserId + StringUtility.GetValiCode();
            }
            PublicUserModel user = new PublicUserModel();

            string  strCompany = string.IsNullOrEmpty(userModels.Company) ? userModels.Store : userModels.Company;
            string  strStore   = string.IsNullOrEmpty(userModels.Company) ? "" : userModels.Store;
            Company company    = ncBase.CurrentEntities.Company.Where(o => o.Name == strCompany && o.CityID == cityId).FirstOrDefault();

            if (company.IsNull())
            {
                company         = new Company();
                company.Name    = strCompany;
                company.Tel     = "";
                company.Address = "";
                company.CityID  = cityId;
                ncBase.CurrentEntities.AddToCompany(company);
                ncBase.CurrentEntities.SaveChanges();
            }


            CompanyStore companyStore = ncBase.CurrentEntities.CompanyStore.Where(o => o.StoreName == strStore && o.CompanyId == company.CompanyId).FirstOrDefault();

            if (!string.IsNullOrEmpty(strStore) && companyStore.IsNull())
            {
                companyStore           = new CompanyStore();
                companyStore.Address   = "";
                companyStore.CityID    = cityId;
                companyStore.CompanyId = company.CompanyId;
                companyStore.StoreName = strStore;
                companyStore.Tel       = "";
                ncBase.CurrentEntities.AddToCompanyStore(companyStore);
                ncBase.CurrentEntities.SaveChanges();
            }
            user.Tel         = userModels.Tel;
            user.Name        = userModels.UserName;
            user.Password    = password;
            user.CityID      = cityId;
            user.DistrictId  = 0;
            user.CompanyId   = company.CompanyId;
            user.StoreId     = companyStore.IsNoNull() ? companyStore.StoreId : 0;
            user.RegionId    = 0;
            user.VipType     = 2; //会员类型
            user.Portrait    = userModels.Portrait;
            user.Remarks     = !string.IsNullOrEmpty(from) ? "From:" + from : "";
            user.IP          = Request.UserHostAddress;
            user.LastLoginIP = Request.UserHostAddress;
            user.NickName    = userName;
            user.EnrolnName  = userName;

            #region 表单验证
            if (string.IsNullOrEmpty(user.Tel))
            {
                return(Json(new { status = 1, msg = "手机号不能为空" }));
            }

            if (string.IsNullOrEmpty(user.Name))
            {
                return(Json(new { status = 1, msg = "用户名不能为空" }));
            }
            if (string.IsNullOrEmpty(user.Password) || (user.Password != null && user.Password.Length < 6))
            {
                return(Json(new { status = 1, msg = "密码至少6位数" }));
            }
            if (user.CityID <= 0)
            {
                return(Json(new { status = 1, msg = "所属城市必填" }));
            }
            if (user.CompanyId <= 0)
            {
                return(Json(new { status = 1, msg = "所属公司必填" }));
            }

            #endregion

            UserBll userBll = new UserBll();
            int     userid  = userBll.addPublicUser(user);
            if (userid == -1)
            {
                return(Json(new { status = 1, msg = "用户名已经存在" }));
            }
            else if (userid == -2)
            {
                return(Json(new { status = 1, msg = "手机号已被注册" }));
            }
            if (userid > 0)//自动登录
            {
                try
                {
                    if (userModels.InviteUid.IsNoNull() && userModels.InviteUid > 0)
                    {
                        PublicUser publicUserInvite =
                            ncBase.CurrentEntities.PublicUser.Where(
                                o => o.UserID == userModels.InviteUid && o.Status == 1).FirstOrDefault();
                        if (publicUserInvite.IsNoNull())
                        {
                            int points = publicUserInvite.Points;
                            publicUserInvite.Points = points + 200;
                            ncBase.CurrentEntities.SaveChanges();

                            PublicUserPointsLog publicUserPointsLog = new PublicUserPointsLog();
                            publicUserPointsLog.Points        = 200;
                            publicUserPointsLog.UserId        = publicUserInvite.UserID;
                            publicUserPointsLog.AddTime       = DateTime.Now;
                            publicUserPointsLog.CurrentPoints = points + 200;
                            publicUserPointsLog.Description   = "手机用户" + user.Tel + "接受邀请注册加分";
                            ncBase.CurrentEntities.AddToPublicUserPointsLog(publicUserPointsLog);
                            ncBase.CurrentEntities.SaveChanges();
                            smsApi.SendSms(publicUserInvite.Tel, "手机用户" + user.Tel + "成功通过您的邀请链接注册房产盒子,系统赠送您200积分!", (Purpose)8, "【房产盒子】");
                        }
                    }
                    SendResult sendResult = smsApi.SendSms(user.Tel, "恭喜您成功开通房产盒子,帐号:" + user.Tel + " 密码:" + user.Password, (Purpose)8, "【房产盒子】");
                }
                catch (Exception)
                {
                    throw;
                }
                if (Session[user.Tel] != null)
                {
                    Session[user.Tel] = null;
                    Session.Remove(user.Tel);
                }
                PublicUserModel newUser = userBll.PublicUserLogin(user.Name, user.Password);
                String          saveKey = System.Configuration.ConfigurationManager.AppSettings["AuthSaveKey"];
                if (String.IsNullOrEmpty(saveKey))
                {
                    saveKey = "WXLoginedUser";
                }
                Session[saveKey] = newUser;
                HttpCookie loginUserCookie = new HttpCookie(saveKey, CryptoUtility.TripleDESEncrypt(newUser.UserID.ToString()));
                loginUserCookie.Expires = DateTime.Now.AddDays(10);
                HttpContext.Response.Cookies.Add(loginUserCookie);
            }
            return(Json(new { status = 0, msg = "注册成功" }));
        }